pmc_mdep.h revision 233628
1255370Sloos/*- 2255370Sloos * This file is in the public domain. 3255370Sloos * 4255370Sloos * from: src/sys/alpha/include/pmc_mdep.h,v 1.2 2005/06/09 19:45:06 jkoshy 5255370Sloos * $FreeBSD: head/sys/mips/include/pmc_mdep.h 233628 2012-03-28 20:58:30Z fabient $ 6255370Sloos */ 7255370Sloos 8255370Sloos#ifndef _MACHINE_PMC_MDEP_H_ 9255370Sloos#define _MACHINE_PMC_MDEP_H_ 10255370Sloos 11255370Sloos#define PMC_MDEP_CLASS_INDEX_MIPS 1 12255370Sloos 13255370Sloosunion pmc_md_op_pmcallocate { 14255370Sloos uint64_t __pad[4]; 15255370Sloos}; 16255370Sloos 17255370Sloos/* Logging */ 18255370Sloos#if defined(__mips_n64) 19255370Sloos#define PMCLOG_READADDR PMCLOG_READ64 20255370Sloos#define PMCLOG_EMITADDR PMCLOG_EMIT64 21255370Sloos#else 22255370Sloos#define PMCLOG_READADDR PMCLOG_READ32 23255370Sloos#define PMCLOG_EMITADDR PMCLOG_EMIT32 24255370Sloos#endif 25255370Sloos 26255370Sloos#if _KERNEL 27255370Sloos 28255370Sloos/* 29255370Sloos * MIPS event codes are encoded with a select bit. The 30255370Sloos * select bit is used when writing to CP0 so that we 31255370Sloos * can select either counter 0/2 or 1/3. The cycle 32255370Sloos * and instruction counters are special in that they 33255370Sloos * can be counted on either 0/2 or 1/3. 34255370Sloos */ 35255370Sloos 36255370Sloos#define MIPS_CTR_ALL 255 /* Count events in any counter. */ 37255370Sloos#define MIPS_CTR_0 0 /* Counter 0 Event */ 38255370Sloos#define MIPS_CTR_1 1 /* Counter 1 Event */ 39255370Sloos 40255370Sloosstruct mips_event_code_map { 41255370Sloos uint32_t pe_ev; /* enum value */ 42255370Sloos uint8_t pe_counter; /* Which counter this can be counted in. */ 43255370Sloos uint8_t pe_code; /* numeric code */ 44255370Sloos}; 45 46struct mips_pmc_spec { 47 uint32_t ps_cpuclass; 48 uint32_t ps_cputype; 49 uint32_t ps_capabilities; 50 int ps_counter_width; 51}; 52 53union pmc_md_pmc { 54 uint32_t pm_mips_evsel; 55}; 56 57#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->pc) 58 59extern const struct mips_event_code_map mips_event_codes[]; 60extern const int mips_event_codes_size; 61extern int mips_npmcs; 62extern struct mips_pmc_spec mips_pmc_spec; 63 64/* 65 * Prototypes 66 */ 67struct pmc_mdep *pmc_mips_initialize(void); 68void pmc_mips_finalize(struct pmc_mdep *_md); 69 70/* 71 * CPU-specific functions 72 */ 73 74uint32_t mips_get_perfctl(int cpu, int ri, uint32_t event, uint32_t caps); 75uint64_t mips_pmcn_read(unsigned int pmc); 76uint64_t mips_pmcn_write(unsigned int pmc, uint64_t v); 77 78#endif /* _KERNEL */ 79 80#endif /* !_MACHINE_PMC_MDEP_H_ */ 81