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