199{
200#define HAS_OPTIONS(x) (cntrs && (cntrs[x].flags || cntrs[x].cnt_mask))
201#define is_fixed_pmc(a) (a == 16 || a == 17 || a == 18)
202
208 uint64_t val;
209 unsigned long plm;
210 unsigned long long fixed_ctr;
211 unsigned int npc, npmc0, npmc1, nf2;
212 unsigned int i, j, n, k, ucode, use_pebs = 0, done_pebs;
214 unsigned int next_gen, last_gen;
215
216 npc = npmc0 = npmc1 = nf2 = 0;
217
225
228
229
230
231
234
235
236
237
238 for(
i=0;
i < n;
i++) {
239
240
241
244
245
246
247
250
252 && e[
i].num_masks > 1) {
253 DPRINT(
"events does not support unit mask combination\n");
255 }
256
257
258
259
260
262 if (++npmc0 > 1) {
263 DPRINT(
"two events compete for a PMC0\n");
265 }
266 }
267
268
269
271 if (++npmc1 > 1) {
272 DPRINT(
"two events compete for a PMC1\n");
274 }
275 }
276
277
278
280 if (++nf2 > 1) {
281 DPRINT(
"two events compete for FIXED_CTR2\n");
283 }
285 DPRINT(
"fixed counters do not support inversion/counter-mask\n");
287 }
288 }
289
290
291
293 unsigned int flags;
294
296
298 if (++nf2 > 1) {
299 DPRINT(
"two events compete for FIXED_CTR2\n");
301 }
303 DPRINT(
"fixed counters do not support inversion/counter-mask\n");
305 }
306 }
307 }
308 }
309
310 next_gen = 0;
311 last_gen = 1;
312
313
314
315
316
317
318
319
320 done_pebs = 0;
321 for(
i=0;
i < n;
i++) {
327 next_gen = 1;
328 done_pebs = 1;
329 }
334 if (next_gen == 1)
335 next_gen = 2;
336 else
337 next_gen = 0;
338 }
339 }
340
341
342
343
344
345
346
347
348
349
351 if (fixed_ctr) {
352 for(
i=0;
i < n;
i++) {
353
355 continue;
356
359 fixed_ctr &= ~1;
360 }
363 fixed_ctr &= ~2;
364 }
367 fixed_ctr &= ~4;
368 }
369 }
370 }
371
372
373
374 for(
i=0;
i < n;
i++) {
375 if (assign_pc[
i] == -1) {
376 for(; next_gen <= last_gen; next_gen++) {
379 break;
380 }
381 if (next_gen <= last_gen)
382 assign_pc[
i] = next_gen++;
383 else {
384 DPRINT(
"cannot assign generic counters\n");
386 }
387 }
388 }
389 j = 0;
390
391
393 k = 0;
394 for (
i=0;
i < n ;
i++ ) {
396 continue;
397 val = 0;
398
401 val |= 1ULL;
403 val |= 2ULL;
404 val |= 1ULL << 3;
405
406 reg.
val |= val << ((assign_pc[
i]-16)<<2);
407 }
408
414
415 __pfm_vbprintf(
"[FIXED_CTRL(pmc%u)=0x%"PRIx64
" pmi0=1 en0=0x%"PRIx64
" pmi1=1 en1=0x%"PRIx64
" pmi2=1 en2=0x%"PRIx64
"] ",
416 pc[npc].reg_num,
419 (reg.
val>>4) & 0x3ULL,
420 (reg.
val>>8) & 0x3ULL);
421
422 if ((fixed_ctr & 0x1) == 0)
424 if ((fixed_ctr & 0x2) == 0)
426 if ((fixed_ctr & 0x4) == 0)
429
430 npc++;
431
432 if ((fixed_ctr & 0x1) == 0)
434 if ((fixed_ctr & 0x2) == 0)
436 if ((fixed_ctr & 0x4) == 0)
438 }
439
440 for (
i=0;
i < n ;
i++ ) {
441
443 continue;
444
446
447
449
451
453
454 ucode = (val >> 8) & 0xff;
455
458 }
459
460
461
462
463
464
466 && ((ucode & (0x3 << 6)) == 0)) {
467 ucode |= 1 << 6;
468 }
469
470
471
472
473
475 && ((ucode & 0xf) == 0)) {
476 ucode |= 0xf;
477 }
478
479 val |= ucode << 8;
480
486
490
491 if (cntrs) {
493
494
495
496
497 if (cntrs[
i].cnt_mask > 255)
500 }
501
506 }
507
512
513 __pfm_vbprintf(
"[PERFEVTSEL%u(pmc%u)=0x%"PRIx64
" event_sel=0x%x umask=0x%x os=%d usr=%d en=%d int=%d inv=%d edge=%d cnt_mask=%d] %s\n",
514 pc[npc].reg_num,
515 pc[npc].reg_num,
527
529 pc[npc].reg_num,
530 pc[npc].reg_num);
531
532 npc++;
533 }
534
535
536
537 for (
i=0;
i < n ;
i++) {
539
543 } else {
546
548 }
549 }
551
552
553
554
555 if (use_pebs && done_pebs) {
556
557
558
565
567 pc[npc].reg_num,
568 pc[npc].reg_value,
569 pc[npc].reg_value & 0x1ull);
570
571 npc++;
572
573 }
575
577}
static pme_core_entry_t core_pe[]
#define PFMLIB_ERR_TOOMANY
static int pfm_regmask_isset(pfmlib_regmask_t *h, unsigned int b)
#define PFMLIB_ERR_NOASSIGN
static int pfm_core_is_fixed(pfmlib_event_t *e, unsigned int f)
int pfm_core_is_pebs(pfmlib_event_t *e)
#define PFMLIB_CORE_ALL_FLAGS
#define PMU_CORE_NUM_COUNTERS
#define PFM_CORE_SEL_EDGE
#define PFMLIB_CORE_UMASK_NCOMBO
#define PFMLIB_CORE_FIXED2_ONLY
#define PFMLIB_CORE_CSPEC
void __pfm_vbprintf(const char *fmt,...)
#define DPRINT(fmt, a...)
unsigned int unit_masks[PFMLIB_MAX_MASKS_PER_EVENT]
pfmlib_reg_t pfp_pmds[PFMLIB_MAX_PMDS]
pfmlib_reg_t pfp_pmcs[PFMLIB_MAX_PMCS]
unsigned int pfp_pmc_count
unsigned int pfp_pmd_count
unsigned long long reg_value
unsigned long reg_alt_addr
unsigned long long reg_addr
pme_core_umask_t pme_umasks[PFMLIB_CORE_MAX_UMASK]
unsigned long sel_cnt_mask
unsigned long sel_event_select
unsigned long sel_unit_mask