1ff7125a6SMarcel Moolenaar /*- 2ff7125a6SMarcel Moolenaar * This file is in the public domain. 3ff7125a6SMarcel Moolenaar * 4ff7125a6SMarcel Moolenaar * $FreeBSD$ 5ff7125a6SMarcel Moolenaar */ 6ff7125a6SMarcel Moolenaar 7ff7125a6SMarcel Moolenaar #ifndef _MACHINE_PMC_MDEP_H_ 8ff7125a6SMarcel Moolenaar #define _MACHINE_PMC_MDEP_H_ 9ff7125a6SMarcel Moolenaar 10a7452468SJustin Hibbits #define PMC_MDEP_CLASS_INDEX_POWERPC 1 11f5f9340bSFabien Thomas 12f263522aSJoseph Koshy union pmc_md_op_pmcallocate { 13*b48a2770SLeandro Lupori uint32_t pm_event; 14f263522aSJoseph Koshy uint64_t __pad[4]; 15f263522aSJoseph Koshy }; 16f263522aSJoseph Koshy 17f263522aSJoseph Koshy /* Logging */ 1851488825SLeandro Lupori #ifdef __powerpc64__ 1951488825SLeandro Lupori #define PMCLOG_READADDR PMCLOG_READ64 2051488825SLeandro Lupori #define PMCLOG_EMITADDR PMCLOG_EMIT64 2151488825SLeandro Lupori #else 22f263522aSJoseph Koshy #define PMCLOG_READADDR PMCLOG_READ32 23f263522aSJoseph Koshy #define PMCLOG_EMITADDR PMCLOG_EMIT32 2451488825SLeandro Lupori #endif 25f263522aSJoseph Koshy 26a7452468SJustin Hibbits #define mtpmr(reg, val) \ 27a7452468SJustin Hibbits __asm __volatile("mtpmr %0,%1" : : "K"(reg), "r"(val)) 28a7452468SJustin Hibbits #define mfpmr(reg) \ 29a7452468SJustin Hibbits ( { register_t val; \ 30a7452468SJustin Hibbits __asm __volatile("mfpmr %0,%1" : "=r"(val) : "K"(reg)); \ 31a7452468SJustin Hibbits val; } ) 32a7452468SJustin Hibbits 33a7452468SJustin Hibbits #define PMR_PMC0 16 34a7452468SJustin Hibbits #define PMR_PMC1 17 35a7452468SJustin Hibbits #define PMR_PMC2 18 36a7452468SJustin Hibbits #define PMR_PMC3 19 37a7452468SJustin Hibbits #define PMR_PMLCa0 144 38a7452468SJustin Hibbits #define PMLCax_FC 0x80000000 39a7452468SJustin Hibbits #define PMLCax_FCS 0x40000000 40a7452468SJustin Hibbits #define PMLCax_FCU 0x20000000 41a7452468SJustin Hibbits #define PMLCax_FCM1 0x10000000 42a7452468SJustin Hibbits #define PMLCax_FCM0 0x08000000 43a7452468SJustin Hibbits #define PMLCax_CE 0x04000000 44a7452468SJustin Hibbits #define PMLCax_EVENT(x) ((x) << 16) 45a7452468SJustin Hibbits #define PMLCax_FCGS1 0x00000002 46a7452468SJustin Hibbits #define PMLCax_FCGS0 0x00000001 47a7452468SJustin Hibbits #define PMR_PMLCa1 145 48a7452468SJustin Hibbits #define PMR_PMLCa2 146 49a7452468SJustin Hibbits #define PMR_PMLCa3 147 50a7452468SJustin Hibbits #define PMR_PMLCb0 272 51a7452468SJustin Hibbits #define PMLCbx_TRIGONCTL(x) ((x) << 28) 52a7452468SJustin Hibbits #define PMLCbx_TRIGOFFCTL(x) ((x) << 24) 53a7452468SJustin Hibbits #define PMLCbx_PMCC 0x00800000 54a7452468SJustin Hibbits #define PMLCbx_PMP(x) ((x) << 13) 55a7452468SJustin Hibbits #define PMLCbx_TREHMUL(x) ((x) << 8) 56a7452468SJustin Hibbits #define PMLCbx_TRESHOLD(x) ((x) << 0) 57a7452468SJustin Hibbits #define PMR_PMLCb1 273 58a7452468SJustin Hibbits #define PMR_PMLCb2 274 59a7452468SJustin Hibbits #define PMR_PMLCb3 275 60a7452468SJustin Hibbits #define PMR_PMGC0 400 61a7452468SJustin Hibbits #define PMGC_FAC 0x80000000 62a7452468SJustin Hibbits #define PMGC_PMIE 0x40000000 63a7452468SJustin Hibbits #define PMGC_FCECE 0x20000000 64a7452468SJustin Hibbits #define PMGC_TBSEL(x) ((x) << 11) 65a7452468SJustin Hibbits #define PMGC_TBEE 0x00000100 66a7452468SJustin Hibbits #define PMR_UPMC0 0 67a7452468SJustin Hibbits #define PMR_UPMC1 1 68a7452468SJustin Hibbits #define PMR_UPMC2 2 69a7452468SJustin Hibbits #define PMR_UPMC3 3 70a7452468SJustin Hibbits #define PMR_UPMLCa0 128 71a7452468SJustin Hibbits #define PMR_UPMLCa1 129 72a7452468SJustin Hibbits #define PMR_UPMLCa2 130 73a7452468SJustin Hibbits #define PMR_UPMLCa3 131 74a7452468SJustin Hibbits #define PMR_UPMLCb0 256 75a7452468SJustin Hibbits #define PMR_UPMLCb1 257 76a7452468SJustin Hibbits #define PMR_UPMLCb2 258 77a7452468SJustin Hibbits #define PMR_UPMLCb3 259 78a7452468SJustin Hibbits #define PMR_UPMGC0 384 79a7452468SJustin Hibbits 80f263522aSJoseph Koshy #if _KERNEL 81f263522aSJoseph Koshy 827b25dccaSJustin Hibbits struct pmc_md_powerpc_pmc { 8368dd7182SLeandro Lupori uint64_t pm_powerpc_overflowcnt; 847b25dccaSJustin Hibbits uint32_t pm_powerpc_evsel; 857b25dccaSJustin Hibbits }; 867b25dccaSJustin Hibbits 87f263522aSJoseph Koshy union pmc_md_pmc { 887b25dccaSJustin Hibbits struct pmc_md_powerpc_pmc pm_powerpc; 89f263522aSJoseph Koshy }; 90f263522aSJoseph Koshy 911c8eb4c4SJustin Hibbits #define PMC_TRAPFRAME_TO_PC(TF) ((TF)->srr0) 921c8eb4c4SJustin Hibbits #define PMC_TRAPFRAME_TO_FP(TF) ((TF)->fixreg[1]) 930da7aa7aSJoseph Koshy #define PMC_TRAPFRAME_TO_SP(TF) (0) 940da7aa7aSJoseph Koshy 95f263522aSJoseph Koshy #endif 96f263522aSJoseph Koshy 97ff7125a6SMarcel Moolenaar #endif /* !_MACHINE_PMC_MDEP_H_ */ 98