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