|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
|
|
Packit |
577717 |
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
Packit |
577717 |
* of this software and associated documentation files (the "Software"), to deal
|
|
Packit |
577717 |
* in the Software without restriction, including without limitation the rights
|
|
Packit |
577717 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
Packit |
577717 |
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
Packit |
577717 |
* subject to the following conditions:
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* The above copyright notice and this permission notice shall be included in all
|
|
Packit |
577717 |
* copies or substantial portions of the Software.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
Packit |
577717 |
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
Packit |
577717 |
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
Packit |
577717 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
Packit |
577717 |
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
Packit |
577717 |
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* This file is part of libpfm, a performance monitoring support library for
|
|
Packit |
577717 |
* applications on Linux/ia64.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
#ifndef __PFMLIB_PRIV_H__
|
|
Packit |
577717 |
#define __PFMLIB_PRIV_H__
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <perfmon/pfmlib.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "pfmlib_priv_comp.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
typedef struct {
|
|
Packit |
577717 |
char *pmu_name;
|
|
Packit |
577717 |
int pmu_type; /* must remain int, using -1 */
|
|
Packit |
577717 |
unsigned int pme_count; /* number of events */
|
|
Packit |
577717 |
unsigned int pmd_count; /* number of PMD registers */
|
|
Packit |
577717 |
unsigned int pmc_count; /* number of PMC registers */
|
|
Packit |
577717 |
unsigned int num_cnt; /* number of counters (counting PMD registers) */
|
|
Packit |
577717 |
unsigned int flags;
|
|
Packit |
577717 |
int (*get_event_code)(unsigned int i, unsigned int cnt, int *code);
|
|
Packit |
577717 |
int (*get_event_mask_code)(unsigned int i, unsigned int mask_idx, unsigned int *code);
|
|
Packit |
577717 |
char *(*get_event_name)(unsigned int i);
|
|
Packit |
577717 |
char *(*get_event_mask_name)(unsigned int event_idx, unsigned int mask_idx);
|
|
Packit |
577717 |
void (*get_event_counters)(unsigned int i, pfmlib_regmask_t *counters);
|
|
Packit |
577717 |
unsigned int (*get_num_event_masks)(unsigned int event_idx);
|
|
Packit |
577717 |
int (*dispatch_events)(pfmlib_input_param_t *p, void *model_in, pfmlib_output_param_t *q, void *model_out);
|
|
Packit |
577717 |
int (*pmu_detect)(void);
|
|
Packit |
577717 |
int (*pmu_init)(void);
|
|
Packit |
577717 |
void (*get_impl_pmcs)(pfmlib_regmask_t *impl_pmcs);
|
|
Packit |
577717 |
void (*get_impl_pmds)(pfmlib_regmask_t *impl_pmds);
|
|
Packit |
577717 |
void (*get_impl_counters)(pfmlib_regmask_t *impl_counters);
|
|
Packit |
577717 |
void (*get_hw_counter_width)(unsigned int *width);
|
|
Packit |
577717 |
int (*get_event_desc)(unsigned int i, char **buf);
|
|
Packit |
577717 |
int (*get_event_mask_desc)(unsigned int event_idx, unsigned int mask_idx, char **buf);
|
|
Packit |
577717 |
int (*get_cycle_event)(pfmlib_event_t *e);
|
|
Packit |
577717 |
int (*get_inst_retired_event)(pfmlib_event_t *e);
|
|
Packit |
577717 |
int (*has_umask_default)(unsigned int i); /* optional */
|
|
Packit |
577717 |
} pfm_pmu_support_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define PFMLIB_MULT_CODE_EVENT 0x1 /* more than one code per event (depending on counter) */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define PFMLIB_CNT_FIRST -1 /* return code for event on first counter */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define PFMLIB_NO_EVT (~0U) /* no event index associated with event */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
typedef struct {
|
|
Packit |
577717 |
pfmlib_options_t options;
|
|
Packit |
577717 |
pfm_pmu_support_t *current;
|
|
Packit |
577717 |
int options_env_set; /* 1 if options set by env variables */
|
|
Packit |
577717 |
} pfm_config_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define PFMLIB_INITIALIZED() (pfm_config.current != NULL)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
extern pfm_config_t pfm_config;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define PFMLIB_DEBUG() pfm_config.options.pfm_debug
|
|
Packit |
577717 |
#define PFMLIB_VERBOSE() pfm_config.options.pfm_verbose
|
|
Packit |
577717 |
#define pfm_current pfm_config.current
|
|
Packit |
577717 |
|
|
Packit |
577717 |
extern void __pfm_vbprintf(const char *fmt,...);
|
|
Packit |
577717 |
extern int __pfm_check_event(pfmlib_event_t *e);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* provided by OS-specific module
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
extern int __pfm_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen);
|
|
Packit |
577717 |
extern void pfm_init_syscalls(void);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifdef PFMLIB_DEBUG
|
|
Packit |
577717 |
#define DPRINT(fmt, a...) \
|
|
Packit |
577717 |
do { \
|
|
Packit |
577717 |
if (pfm_config.options.pfm_debug) { \
|
|
Packit |
577717 |
fprintf(libpfm_fp, "%s (%s.%d): " fmt, __FILE__, __func__, __LINE__, ## a); } \
|
|
Packit |
577717 |
} while (0)
|
|
Packit |
577717 |
#else
|
|
Packit |
577717 |
#define DPRINT(a)
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define ALIGN_DOWN(a,p) ((a) & ~((1UL<<(p))-1))
|
|
Packit |
577717 |
#define ALIGN_UP(a,p) ((((a) + ((1UL<<(p))-1))) & ~((1UL<<(p))-1))
|
|
Packit |
577717 |
|
|
Packit |
577717 |
extern pfm_pmu_support_t crayx2_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t montecito_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t itanium2_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t itanium_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t generic_ia64_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t amd64_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t i386_p6_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t i386_ppro_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t i386_pii_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t i386_pm_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t gen_ia32_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t generic_mips64_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t sicortex_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t pentium4_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t coreduo_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t core_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t gen_powerpc_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t sparc_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t cell_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t intel_atom_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t intel_nhm_support;
|
|
Packit |
577717 |
extern pfm_pmu_support_t intel_wsm_support;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static inline unsigned int pfm_num_masks(int e)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
if (pfm_current->get_num_event_masks == NULL)
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
return pfm_current->get_num_event_masks(e);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
extern FILE *libpfm_fp;
|
|
Packit |
577717 |
extern int forced_pmu;
|
|
Packit |
577717 |
extern int _pfmlib_sys_base; /* syscall base */
|
|
Packit |
577717 |
extern int _pfmlib_major_version; /* kernel perfmon major version */
|
|
Packit |
577717 |
extern int _pfmlib_minor_version; /* kernel perfmon minor version */
|
|
Packit |
577717 |
extern void pfm_init_syscalls(void);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static inline int
|
|
Packit |
577717 |
_pfmlib_get_sys_base()
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
if (!_pfmlib_sys_base)
|
|
Packit |
577717 |
pfm_init_syscalls();
|
|
Packit |
577717 |
return _pfmlib_sys_base;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
#endif /* __PFMLIB_PRIV_H__ */
|