1 /*- 2 * Copyright (c) 2003,2004 Joseph Koshy 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #ifndef _PMC_H_ 30 #define _PMC_H_ 31 32 #include <sys/pmc.h> 33 34 /* 35 * Prototypes 36 */ 37 38 int pmc_allocate(const char *_ctrspec, enum pmc_mode _mode, uint32_t _flags, 39 int _cpu, pmc_id_t *_pmcid); 40 int pmc_attach(pmc_id_t _pmcid, pid_t _pid); 41 int pmc_capabilities(pmc_id_t _pmc, uint32_t *_caps); 42 int pmc_configure_logfile(int _fd); 43 int pmc_detach(pmc_id_t _pmcid, pid_t _pid); 44 int pmc_disable(int _cpu, int _pmc); 45 int pmc_enable(int _cpu, int _pmc); 46 int pmc_get_driver_stats(struct pmc_op_getdriverstats *_gms); 47 int pmc_init(void); 48 int pmc_read(pmc_id_t _pmc, pmc_value_t *_value); 49 int pmc_release(pmc_id_t _pmc); 50 int pmc_rw(pmc_id_t _pmc, pmc_value_t _newvalue, pmc_value_t *_oldvalue); 51 int pmc_set(pmc_id_t _pmc, pmc_value_t _value); 52 int pmc_start(pmc_id_t _pmc); 53 int pmc_stop(pmc_id_t _pmc); 54 int pmc_width(pmc_id_t _pmc, uint32_t *_width); 55 int pmc_write(pmc_id_t _pmc, pmc_value_t _value); 56 57 int pmc_ncpu(void); 58 int pmc_npmc(int _cpu); 59 int pmc_cpuinfo(const struct pmc_op_getcpuinfo **_cpu_info); 60 int pmc_pmcinfo(int _cpu, struct pmc_op_getpmcinfo **_pmc_info); 61 62 const char *pmc_name_of_capability(uint32_t _c); 63 const char *pmc_name_of_class(enum pmc_class _pc); 64 const char *pmc_name_of_cputype(enum pmc_cputype _cp); 65 const char *pmc_name_of_disposition(enum pmc_disp _pd); 66 const char *pmc_name_of_event(enum pmc_event _pe); 67 const char *pmc_name_of_mode(enum pmc_mode _pm); 68 const char *pmc_name_of_state(enum pmc_state _ps); 69 70 int pmc_event_names_of_class(enum pmc_class _cl, const char ***_eventnames, 71 int *_nevents); 72 73 /* 74 * Architecture specific extensions 75 */ 76 77 #if __i386__ || __amd64__ 78 int pmc_x86_get_msr(pmc_id_t _pmc, uint32_t *_msr); 79 #endif 80 81 #endif 82