pmc.h revision 190395
1193323Sed/*- 2193323Sed * Copyright (c) 2003,2004 Joseph Koshy 3193323Sed * All rights reserved. 4193323Sed * 5193323Sed * Redistribution and use in source and binary forms, with or without 6193323Sed * modification, are permitted provided that the following conditions 7193323Sed * are met: 8193323Sed * 1. Redistributions of source code must retain the above copyright 9193323Sed * notice, this list of conditions and the following disclaimer. 10193323Sed * 2. Redistributions in binary form must reproduce the above copyright 11193323Sed * notice, this list of conditions and the following disclaimer in the 12193323Sed * documentation and/or other materials provided with the distribution. 13193323Sed * 14193323Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15193323Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16193323Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17193323Sed * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18234353Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19193323Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20193323Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21193323Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22193323Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23239462Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24193323Sed * SUCH DAMAGE. 25193323Sed * 26193323Sed * $FreeBSD: head/lib/libpmc/pmc.h 190395 2009-03-24 22:35:05Z fabient $ 27193323Sed */ 28193323Sed 29193323Sed#ifndef _PMC_H_ 30193323Sed#define _PMC_H_ 31193323Sed 32198090Srdivacky#include <sys/cdefs.h> 33198090Srdivacky#include <sys/pmc.h> 34234353Sdim 35193323Sed/* 36239462Sdim * Driver statistics. 37193323Sed */ 38193323Sedstruct pmc_driverstats { 39193323Sed int pm_intr_ignored; /* #interrupts ignored */ 40193323Sed int pm_intr_processed; /* #interrupts processed */ 41193323Sed int pm_intr_bufferfull; /* #interrupts with ENOSPC */ 42239462Sdim int pm_syscalls; /* #syscalls */ 43239462Sdim int pm_syscall_errors; /* #syscalls with errors */ 44239462Sdim int pm_buffer_requests; /* #buffer requests */ 45239462Sdim int pm_buffer_requests_failed; /* #failed buffer requests */ 46193323Sed int pm_log_sweeps; /* #sample buffer processing passes */ 47193323Sed}; 48239462Sdim 49218893Sdim/* 50218893Sdim * CPU information. 51234353Sdim */ 52218893Sdimstruct pmc_cpuinfo { 53234353Sdim enum pmc_cputype pm_cputype; /* the kind of CPU */ 54218893Sdim uint32_t pm_ncpu; /* number of CPUs */ 55218893Sdim uint32_t pm_npmc; /* #PMCs per CPU */ 56218893Sdim uint32_t pm_nclass; /* #classes of PMCs */ 57193323Sed struct pmc_classinfo pm_classes[PMC_CLASS_MAX]; 58193323Sed}; 59198090Srdivacky 60193323Sed/* 61193323Sed * Current PMC state. 62212904Sdim */ 63193323Sedstruct pmc_pmcinfo { 64234353Sdim int32_t pm_cpu; /* CPU number */ 65239462Sdim struct pmc_info pm_pmcs[]; /* NPMC structs */ 66193323Sed}; 67198892Srdivacky 68198892Srdivacky/* 69193323Sed * Prototypes 70193323Sed */ 71193323Sed 72239462Sdim__BEGIN_DECLS 73239462Sdimint pmc_allocate(const char *_ctrspec, enum pmc_mode _mode, uint32_t _flags, 74239462Sdim int _cpu, pmc_id_t *_pmcid); 75239462Sdimint pmc_attach(pmc_id_t _pmcid, pid_t _pid); 76239462Sdimint pmc_capabilities(pmc_id_t _pmc, uint32_t *_caps); 77239462Sdimint pmc_configure_logfile(int _fd); 78239462Sdimint pmc_flush_logfile(void); 79239462Sdimint pmc_detach(pmc_id_t _pmcid, pid_t _pid); 80239462Sdimint pmc_disable(int _cpu, int _pmc); 81193323Sedint pmc_enable(int _cpu, int _pmc); 82193323Sedint pmc_get_driver_stats(struct pmc_driverstats *_gms); 83239462Sdimint pmc_get_msr(pmc_id_t _pmc, uint32_t *_msr); 84239462Sdimint pmc_init(void); 85239462Sdimint pmc_read(pmc_id_t _pmc, pmc_value_t *_value); 86234353Sdimint pmc_release(pmc_id_t _pmc); 87234353Sdimint pmc_rw(pmc_id_t _pmc, pmc_value_t _newvalue, pmc_value_t *_oldvalue); 88234353Sdimint pmc_set(pmc_id_t _pmc, pmc_value_t _value); 89198090Srdivackyint pmc_start(pmc_id_t _pmc); 90239462Sdimint pmc_stop(pmc_id_t _pmc); 91239462Sdimint pmc_width(pmc_id_t _pmc, uint32_t *_width); 92239462Sdimint pmc_write(pmc_id_t _pmc, pmc_value_t _value); 93239462Sdimint pmc_writelog(uint32_t _udata); 94210299Sed 95210299Sedint pmc_ncpu(void); 96193323Sedint pmc_npmc(int _cpu); 97193323Sedint pmc_cpuinfo(const struct pmc_cpuinfo **_cpu_info); 98193323Sedint pmc_pmcinfo(int _cpu, struct pmc_pmcinfo **_pmc_info); 99193323Sed 100193323Sedconst char *pmc_name_of_capability(uint32_t _c); 101239462Sdimconst char *pmc_name_of_class(enum pmc_class _pc); 102239462Sdimconst char *pmc_name_of_cputype(enum pmc_cputype _cp); 103239462Sdimconst char *pmc_name_of_disposition(enum pmc_disp _pd); 104239462Sdimconst char *pmc_name_of_event(enum pmc_event _pe); 105239462Sdimconst char *pmc_name_of_mode(enum pmc_mode _pm); 106239462Sdimconst char *pmc_name_of_state(enum pmc_state _ps); 107239462Sdim 108239462Sdimint pmc_event_names_of_class(enum pmc_class _cl, const char ***_eventnames, 109239462Sdim int *_nevents); 110239462Sdim__END_DECLS 111239462Sdim 112239462Sdim#endif 113239462Sdim