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