PAPI 7.1.0.0
Loading...
Searching...
No Matches
pfmlib_itanium.h
Go to the documentation of this file.
1/*
2 * Itanium PMU specific types and definitions
3 *
4 * Copyright (c) 2001-2006 Hewlett-Packard Development Company, L.P.
5 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24#ifndef __PFMLIB_ITANIUM_H__
25#define __PFMLIB_ITANIUM_H__
26
27#include <perfmon/pfmlib.h>
28#include <endian.h>
29
30#if BYTE_ORDER != LITTLE_ENDIAN
31#error "this file only supports little endian environments"
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#define PMU_ITA_FIRST_COUNTER 4 /* index of first PMC/PMD counter */
39#define PMU_ITA_NUM_COUNTERS 4 /* total numbers of PMC/PMD pairs used as counting monitors */
40#define PMU_ITA_NUM_PMCS 14 /* total number of PMCS defined */
41#define PMU_ITA_NUM_PMDS 18 /* total number of PMDS defined */
42#define PMU_ITA_NUM_BTB 8 /* total number of PMDS in BTB */
43#define PMU_ITA_COUNTER_WIDTH 32 /* hardware counter bit width */
44
45
46/*
47 * This structure provides a detailed way to setup a PMC register.
48 */
49typedef union {
50 unsigned long pmc_val; /* complete register value */
51
52 /* This is the Itanium-specific PMC layout for counter config */
53 struct {
54 unsigned long pmc_plm:4; /* privilege level mask */
55 unsigned long pmc_ev:1; /* external visibility */
56 unsigned long pmc_oi:1; /* overflow interrupt */
57 unsigned long pmc_pm:1; /* privileged monitor */
58 unsigned long pmc_ig1:1; /* reserved */
59 unsigned long pmc_es:7; /* event select */
60 unsigned long pmc_ig2:1; /* reserved */
61 unsigned long pmc_umask:4; /* unit mask */
62 unsigned long pmc_thres:3; /* threshold */
63 unsigned long pmc_ig3:1; /* reserved (missing from table on p6-17) */
64 unsigned long pmc_ism:2; /* instruction set mask */
65 unsigned long pmc_ig4:38; /* reserved */
66 } pmc_ita_count_reg;
67
68 /* Opcode matcher */
69 struct {
70 unsigned long ignored1:3;
71 unsigned long mask:27; /* mask encoding bits {40:27}{12:0} */
72 unsigned long ignored2:3;
73 unsigned long match:27; /* match encoding bits {40:27}{12:0} */
74 unsigned long b:1; /* B-syllable */
75 unsigned long f:1; /* F-syllable */
76 unsigned long i:1; /* I-syllable */
77 unsigned long m:1; /* M-syllable */
78 } pmc8_9_ita_reg;
79
80 /* Instruction Event Address Registers */
81 struct {
82 unsigned long iear_plm:4; /* privilege level mask */
83 unsigned long iear_ig1:2; /* reserved */
84 unsigned long iear_pm:1; /* privileged monitor */
85 unsigned long iear_tlb:1; /* cache/tlb mode */
86 unsigned long iear_ig2:8; /* reserved */
87 unsigned long iear_umask:4; /* unit mask */
88 unsigned long iear_ig3:4; /* reserved */
89 unsigned long iear_ism:2; /* instruction set */
90 unsigned long iear_ig4:38; /* reserved */
91 } pmc10_ita_reg;
92
93 /* Data Event Address Registers */
94 struct {
95 unsigned long dear_plm:4; /* privilege level mask */
96 unsigned long dear_ig1:2; /* reserved */
97 unsigned long dear_pm:1; /* privileged monitor */
98 unsigned long dear_tlb:1; /* cache/tlb mode */
99 unsigned long dear_ig2:8; /* reserved */
100 unsigned long dear_umask:4; /* unit mask */
101 unsigned long dear_ig3:4; /* reserved */
102 unsigned long dear_ism:2; /* instruction set */
103 unsigned long dear_ig4:2; /* reserved */
104 unsigned long dear_pt:1; /* pass tags */
105 unsigned long dear_ig5:35; /* reserved */
106 } pmc11_ita_reg;
107
108 /* Branch Trace Buffer registers */
109 struct {
110 unsigned long btbc_plm:4; /* privilege level */
111 unsigned long btbc_ig1:2;
112 unsigned long btbc_pm:1; /* privileged monitor */
113 unsigned long btbc_tar:1; /* target address register */
114 unsigned long btbc_tm:2; /* taken mask */
115 unsigned long btbc_ptm:2; /* predicted taken address mask */
116 unsigned long btbc_ppm:2; /* predicted predicate mask */
117 unsigned long btbc_bpt:1; /* branch prediction table */
118 unsigned long btbc_bac:1; /* branch address calculator */
119 unsigned long btbc_ig2:48;
120 } pmc12_ita_reg;
121
122 struct {
123 unsigned long irange_ta:1; /* tag all bit */
124 unsigned long irange_ig:63;
125 } pmc13_ita_reg;
127
128typedef union {
129 unsigned long pmd_val; /* counter value */
130
131 /* counting pmd register */
132 struct {
133 unsigned long pmd_count:32; /* 32-bit hardware counter */
134 unsigned long pmd_sxt32:32; /* sign extension of bit 32 */
135 } pmd_ita_counter_reg;
136
137 struct {
138 unsigned long iear_v:1; /* valid bit */
139 unsigned long iear_tlb:1; /* tlb miss bit */
140 unsigned long iear_ig1:3; /* reserved */
141 unsigned long iear_icla:59; /* instruction cache line address {60:51} sxt {50}*/
142 } pmd0_ita_reg;
143
144 struct {
145 unsigned long iear_lat:12; /* latency */
146 unsigned long iear_ig1:52; /* reserved */
147 } pmd1_ita_reg;
148
149 struct {
150 unsigned long dear_daddr; /* data address */
151 } pmd2_ita_reg;
152
153 struct {
154 unsigned long dear_latency:12; /* latency */
155 unsigned long dear_ig1:50; /* reserved */
156 unsigned long dear_level:2; /* level */
157 } pmd3_ita_reg;
158
159 struct {
160 unsigned long btb_b:1; /* branch bit */
161 unsigned long btb_mp:1; /* mispredict bit */
162 unsigned long btb_slot:2; /* which slot, 3=not taken branch */
163 unsigned long btb_addr:60; /* b=1, bundle address, b=0 target address */
164 } pmd8_15_ita_reg;
165
166 struct {
167 unsigned long btbi_bbi:3; /* branch buffer index */
168 unsigned long btbi_full:1; /* full bit (sticky) */
169 unsigned long btbi_ignored:60;
170 } pmd16_ita_reg;
171
172 struct {
173 unsigned long dear_vl:1; /* valid bit */
174 unsigned long dear_ig1:1; /* reserved */
175 unsigned long dear_slot:2; /* slot number */
176 unsigned long dear_iaddr:60; /* instruction address */
177 } pmd17_ita_reg;
179
180/*
181 * type definition for Itanium instruction set support
182 */
183typedef enum {
184 PFMLIB_ITA_ISM_BOTH=0, /* IA-32 and IA-64 (default) */
185 PFMLIB_ITA_ISM_IA32=1, /* IA-32 only */
186 PFMLIB_ITA_ISM_IA64=2 /* IA-64 only */
188
189typedef struct {
190 unsigned int flags; /* counter specific flags */
191 unsigned int thres; /* per event threshold */
192 pfmlib_ita_ism_t ism; /* per event instruction set */
194
195/*
196 * counter specific flags
197 */
198#define PFMLIB_ITA_FL_EVT_NO_QUALCHECK 0x1 /* don't check qualifier constraints */
199
200typedef struct {
201 unsigned char opcm_used; /* set to 1 if this opcode matcher is used */
202 unsigned long pmc_val; /* value of opcode matcher for PMC8 */
204
205/*
206 *
207 * The BTB can be configured via 4 different methods:
208 *
209 * - BRANCH_EVENT is in the event list, pfp_ita_btb.btb_used == 0:
210 * The BTB will be configured (PMC12) to record all branches AND a counting
211 * monitor will be setup to count BRANCH_EVENT.
212 *
213 * - BRANCH_EVENT is in the event list, pfp_ita_btb.btb_used == 1:
214 * The BTB will be configured (PMC12) according to information in pfp_ita_btb AND
215 * a counter will be setup to count BRANCH_EVENT.
216 *
217 * - BRANCH_EVENT is NOT in the event list, pfp_ita_btb.btb_used == 0:
218 * Nothing is programmed
219 *
220 * - BRANCH_EVENT is NOT in the event list, pfp_ita_btb.btb_used == 1:
221 * The BTB will be configured (PMC12) according to information in pfp_ita_btb.
222 * This is the free running BTB mode.
223 */
224typedef struct {
225 unsigned char btb_used; /* set to 1 if the BTB is used */
226
227 unsigned char btb_tar;
228 unsigned char btb_tac;
229 unsigned char btb_bac;
230 unsigned char btb_tm;
231 unsigned char btb_ptm;
232 unsigned char btb_ppm;
233 unsigned int btb_plm; /* BTB privilege level mask */
235
236/*
237 * There are four ways to configure EAR:
238 *
239 * - an EAR event is in the event list AND pfp_ita_ear.ear_used = 0:
240 * The EAR will be programmed (PMC10 or PMC11) based on the information encoded in the
241 * event (umask, cache, tlb). A counting monitor will be programmed to
242 * count DATA_EAR_EVENTS or INSTRUCTION_EAR_EVENTS depending on the type of EAR.
243 *
244 * - an EAR event is in the event list AND pfp_ita_ear.ear_used = 1:
245 * The EAR will be programmed (PMC10 or PMC11) according to the information in the
246 * pfp_ita_ear structure because it contains more detailed information
247 * (such as priv level and instruction set). A counting monitor will be programmed
248 * to count DATA_EAR_EVENTS or INSTRUCTION_EAR_EVENTS depending on the type of EAR.
249 *
250 * - no EAR event is in the event list AND pfp_ita_ear.ear_used = 0:
251 * Nothing is programmed.
252 *
253 * - no EAR event is in the event list AND pfp_ita_ear.ear_used = 1:
254 * The EAR will be programmed (PMC10 or PMC11) according to the information in the
255 * pfp_ita_ear structure. This is the free running mode for EAR
256 */
257typedef enum {
258 PFMLIB_ITA_EAR_CACHE_MODE=0, /* Cache mode : I-EAR and D-EAR */
259 PFMLIB_ITA_EAR_TLB_MODE =1, /* TLB mode : I-EAR and D-EAR */
261
262
263typedef struct {
264 unsigned char ear_used; /* when set will force definition of PMC[10] */
265
267 pfmlib_ita_ism_t ear_ism; /* instruction set */
268 unsigned int ear_plm; /* IEAR privilege level mask */
269 unsigned long ear_umask; /* umask value for PMC10 */
271
272/*
273 * describes one range. rr_plm is ignored for data ranges
274 * a range is interpreted as unused (not defined) when rr_start = rr_end = 0.
275 * if rr_plm is not set it will use the default settings set in the generic
276 * library param structure.
277 */
278typedef struct {
279 unsigned int rr_flags; /* currently unused */
280 unsigned int rr_plm; /* privilege level (ignored for data ranges) */
281 unsigned long rr_start; /* start address */
282 unsigned long rr_end; /* end address (not included) */
284
285typedef struct {
286 unsigned long rr_soff; /* output: start offset from actual start */
287 unsigned long rr_eoff; /* output: end offset from actual end */
289
290
291/*
292 * rr_used must be set to true for the library to configure the debug registers.
293 * If using less than 4 intervals, must mark the end with entry: rr_limits[x].rr_start = rr_limits[x].rr_end = 0
294 */
295typedef struct {
296 unsigned char rr_used; /* set if address range restriction is used */
297 unsigned int rr_flags; /* set of flags for all ranges */
298 unsigned int rr_nbr_used; /* how many registers were used (output) */
299 pfmlib_ita_input_rr_desc_t rr_limits[4]; /* at most 4 distinct intervals */
301
302typedef struct {
303 unsigned int rr_nbr_used; /* how many registers were used (output) */
304 pfmlib_ita_output_rr_desc_t rr_infos[4]; /* at most 4 distinct intervals */
305 pfmlib_reg_t rr_br[8]; /* array of debug reg requests to configure */
307
308
309/*
310 * Itanium specific parameters for the library
311 */
312typedef struct {
313 pfmlib_ita_counter_t pfp_ita_counters[PMU_ITA_NUM_COUNTERS]; /* extended counter features */
314
315 unsigned long pfp_ita_flags; /* Itanium specific flags */
316
317 pfmlib_ita_opcm_t pfp_ita_pmc8; /* PMC8 (opcode matcher) configuration */
318 pfmlib_ita_opcm_t pfp_ita_pmc9; /* PMC9 (opcode matcher) configuration */
319 pfmlib_ita_ear_t pfp_ita_iear; /* IEAR configuration */
320 pfmlib_ita_ear_t pfp_ita_dear; /* DEAR configuration */
321 pfmlib_ita_btb_t pfp_ita_btb; /* BTB configuration */
322
323 pfmlib_ita_input_rr_t pfp_ita_drange; /* data range restrictions */
324 pfmlib_ita_input_rr_t pfp_ita_irange; /* code range restrictions */
325 unsigned long reserved[1]; /* for future use */
327
328typedef struct {
329 pfmlib_ita_output_rr_t pfp_ita_drange; /* data range restrictions */
330 pfmlib_ita_output_rr_t pfp_ita_irange; /* code range restrictions */
331 unsigned long reserved[6]; /* for future use */
333
334extern int pfm_ita_is_ear(unsigned int i);
335extern int pfm_ita_is_dear(unsigned int i);
336extern int pfm_ita_is_dear_tlb(unsigned int i);
337extern int pfm_ita_is_dear_cache(unsigned int i);
338extern int pfm_ita_is_iear(unsigned int i);
339extern int pfm_ita_is_iear_tlb(unsigned int i);
340extern int pfm_ita_is_iear_cache(unsigned int i);
341extern int pfm_ita_is_btb(unsigned int i);
342extern int pfm_ita_support_opcm(unsigned int i);
343extern int pfm_ita_support_iarr(unsigned int i);
344extern int pfm_ita_support_darr(unsigned int i);
345extern int pfm_ita_get_ear_mode(unsigned int i, pfmlib_ita_ear_mode_t *m);
346
347extern int pfm_ita_get_event_maxincr(unsigned int i, unsigned int *maxincr);
348extern int pfm_ita_get_event_umask(unsigned int i, unsigned long *umask);
349
350#ifdef __cplusplus /* extern C */
351}
352#endif
353
354#endif /* __PFMLIB_ITANIUM_H__ */
int i
uint16_t reserved
int pfm_ita_support_iarr(unsigned int i)
int pfm_ita_is_btb(unsigned int i)
int pfm_ita_support_darr(unsigned int i)
int pfm_ita_get_event_maxincr(unsigned int i, unsigned int *maxincr)
pfmlib_ita_ism_t
@ PFMLIB_ITA_ISM_IA64
@ PFMLIB_ITA_ISM_IA32
@ PFMLIB_ITA_ISM_BOTH
int pfm_ita_get_ear_mode(unsigned int i, pfmlib_ita_ear_mode_t *m)
pfmlib_ita_ear_mode_t
@ PFMLIB_ITA_EAR_TLB_MODE
@ PFMLIB_ITA_EAR_CACHE_MODE
#define PMU_ITA_NUM_COUNTERS
int pfm_ita_is_dear_tlb(unsigned int i)
int pfm_ita_get_event_umask(unsigned int i, unsigned long *umask)
int pfm_ita_is_iear_tlb(unsigned int i)
int pfm_ita_support_opcm(unsigned int i)
int pfm_ita_is_dear(unsigned int i)
int pfm_ita_is_ear(unsigned int i)
int pfm_ita_is_iear_cache(unsigned int i)
int pfm_ita_is_iear(unsigned int i)
int pfm_ita_is_dear_cache(unsigned int i)
unsigned char btb_used
unsigned char btb_tm
unsigned int btb_plm
unsigned char btb_ppm
unsigned char btb_ptm
unsigned char btb_tar
unsigned char btb_bac
unsigned char btb_tac
pfmlib_ita_ism_t ism
pfmlib_ita_ism_t ear_ism
unsigned long ear_umask
pfmlib_ita_ear_mode_t ear_mode
unsigned char ear_used
unsigned int ear_plm
pfmlib_ita_opcm_t pfp_ita_pmc9
pfmlib_ita_btb_t pfp_ita_btb
pfmlib_ita_input_rr_t pfp_ita_drange
pfmlib_ita_opcm_t pfp_ita_pmc8
pfmlib_ita_input_rr_t pfp_ita_irange
pfmlib_ita_ear_t pfp_ita_dear
pfmlib_ita_ear_t pfp_ita_iear
unsigned int rr_nbr_used
unsigned long pmc_val
unsigned char opcm_used
pfmlib_ita_output_rr_t pfp_ita_irange
pfmlib_ita_output_rr_t pfp_ita_drange
unsigned long dear_ig3
unsigned long dear_ig1
unsigned long irange_ta
unsigned long pmc_umask
unsigned long pmc_ig3
unsigned long pmc_plm
unsigned long btbc_tm
unsigned long dear_tlb
unsigned long pmc_ig4
unsigned long match
unsigned long dear_pm
unsigned long btbc_tar
unsigned long i
unsigned long pmc_ig2
unsigned long b
unsigned long dear_umask
unsigned long btbc_ppm
unsigned long m
unsigned long dear_ig2
unsigned long ignored1
unsigned long f
unsigned long iear_ig3
unsigned long iear_plm
unsigned long btbc_pm
unsigned long btbc_bac
unsigned long pmc_thres
unsigned long iear_ig4
unsigned long btbc_ig2
unsigned long dear_ig5
unsigned long mask
unsigned long iear_pm
unsigned long dear_ism
unsigned long btbc_ig1
unsigned long iear_umask
unsigned long pmc_val
unsigned long iear_ism
unsigned long irange_ig
unsigned long pmc_oi
unsigned long iear_ig1
unsigned long pmc_es
unsigned long dear_ig4
unsigned long pmc_pm
unsigned long iear_ig2
unsigned long ignored2
unsigned long iear_tlb
unsigned long pmc_ism
unsigned long pmc_ev
unsigned long dear_pt
unsigned long btbc_bpt
unsigned long pmc_ig1
unsigned long btbc_ptm
unsigned long dear_plm
unsigned long btbc_plm
unsigned long btbi_ignored
unsigned long btbi_full
unsigned long btbi_bbi
unsigned long pmd_count
unsigned long iear_lat
unsigned long dear_daddr
unsigned long iear_v
unsigned long dear_vl
unsigned long btb_addr
unsigned long pmd_sxt32
unsigned long dear_slot
unsigned long btb_slot
unsigned long iear_icla
unsigned long dear_level
unsigned long btb_b
unsigned long iear_tlb
unsigned long dear_latency
unsigned long dear_iaddr
unsigned long dear_ig1
unsigned long pmd_val
unsigned long iear_ig1
unsigned long btb_mp