PAPI 7.1.0.0
Loading...
Searching...
No Matches
pfmlib_sicortex.c File Reference
Include dependency graph for pfmlib_sicortex.c:

Go to the source code of this file.

Macros

#define sel_event_mask   perfsel.sel_event_mask
 
#define sel_exl   perfsel.sel_exl
 
#define sel_os   perfsel.sel_os
 
#define sel_usr   perfsel.sel_usr
 
#define sel_sup   perfsel.sel_sup
 
#define sel_int   perfsel.sel_int
 
#define core_counters   2
 
#define MAX_ICE9_PMCS   2+4+256
 
#define MAX_ICE9_PMDS   2+4+256
 

Functions

static int compute_ice9_counters (int type)
 
static int pfm_sicortex_detect (void)
 
static void stuff_sicortex_regs (pfmlib_event_t *e, int plm, pfmlib_reg_t *pc, pfmlib_reg_t *pd, int cntr, int j, pfmlib_sicortex_input_param_t *mod_in)
 
static int stuff_sicortex_scb_control_regs (pfmlib_reg_t *pc, pfmlib_reg_t *pd, int num, pfmlib_sicortex_input_param_t *mod_in)
 
static int pfm_sicortex_dispatch_counters (pfmlib_input_param_t *inp, pfmlib_sicortex_input_param_t *mod_in, pfmlib_output_param_t *outp)
 
static int pfm_sicortex_dispatch_events (pfmlib_input_param_t *inp, void *model_in, pfmlib_output_param_t *outp, void *model_out)
 
static int pfm_sicortex_get_event_code (unsigned int i, unsigned int cnt, int *code)
 
int pfm_sicortex_get_event_umask (unsigned int i, unsigned long *umask)
 
static void pfm_sicortex_get_event_counters (unsigned int j, pfmlib_regmask_t *counters)
 
static void pfm_sicortex_get_impl_perfsel (pfmlib_regmask_t *impl_pmcs)
 
static void pfm_sicortex_get_impl_perfctr (pfmlib_regmask_t *impl_pmds)
 
static void pfm_sicortex_get_impl_counters (pfmlib_regmask_t *impl_counters)
 
static void pfm_sicortex_get_hw_counter_width (unsigned int *width)
 
static char * pfm_sicortex_get_event_name (unsigned int i)
 
static int pfm_sicortex_get_event_description (unsigned int ev, char **str)
 
static int pfm_sicortex_get_cycle_event (pfmlib_event_t *e)
 
static int pfm_sicortex_get_inst_retired (pfmlib_event_t *e)
 
int pfm_sicortex_is_cpu (unsigned int i)
 
int pfm_sicortex_is_scb (unsigned int i)
 
int pfm_sicortex_support_domain (unsigned int i)
 
int pfm_sicortex_support_vpc_pea (unsigned int i)
 
static char * pfm_sicortex_get_event_mask_name (unsigned int ev, unsigned int midx)
 
static int pfm_sicortex_get_event_mask_desc (unsigned int ev, unsigned int midx, char **str)
 
static unsigned int pfm_sicortex_get_num_event_masks (unsigned int ev)
 
static int pfm_sicortex_get_event_mask_code (unsigned int ev, unsigned int midx, unsigned int *code)
 
static int pfm_sicortex_has_umask_default (unsigned int ev)
 

Variables

static pme_sicortex_entry_tsicortex_pe = NULL
 
pfm_pmu_support_t sicortex_support
 

Macro Definition Documentation

◆ core_counters

#define core_counters   2

Definition at line 57 of file pfmlib_sicortex.c.

◆ MAX_ICE9_PMCS

#define MAX_ICE9_PMCS   2+4+256

Definition at line 59 of file pfmlib_sicortex.c.

◆ MAX_ICE9_PMDS

#define MAX_ICE9_PMDS   2+4+256

Definition at line 60 of file pfmlib_sicortex.c.

◆ sel_event_mask

#define sel_event_mask   perfsel.sel_event_mask

Definition at line 47 of file pfmlib_sicortex.c.

◆ sel_exl

#define sel_exl   perfsel.sel_exl

Definition at line 48 of file pfmlib_sicortex.c.

◆ sel_int

#define sel_int   perfsel.sel_int

Definition at line 52 of file pfmlib_sicortex.c.

◆ sel_os

#define sel_os   perfsel.sel_os

Definition at line 49 of file pfmlib_sicortex.c.

◆ sel_sup

#define sel_sup   perfsel.sel_sup

Definition at line 51 of file pfmlib_sicortex.c.

◆ sel_usr

#define sel_usr   perfsel.sel_usr

Definition at line 50 of file pfmlib_sicortex.c.

Function Documentation

◆ compute_ice9_counters()

static int compute_ice9_counters ( int  type)
static

Definition at line 62 of file pfmlib_sicortex.c.

63{
64 int i;
65 int bound = 0;
67
70 for (i=0;i<MAX_ICE9_PMDS;i++)
71 {
72 char tmp[1024];
73 sprintf(tmp,"/sys/kernel/perfmon/pmu_desc/pmd%d",i);
74 if (access(tmp,F_OK) == 0)
76 }
77 for (i=0;i<MAX_ICE9_PMCS;i++)
78 {
79 char tmp[1024];
80 sprintf(tmp,"/sys/kernel/perfmon/pmu_desc/pmc%d",i);
81 if (access(tmp,F_OK) == 0)
83 }
84
85 /* Compute the max */
86
88 gen_mips64_pe = gen_mips64_ice9a_pe;
89// core_counters = 2;
90 bound = (sizeof(gen_mips64_ice9a_pe)/sizeof(pme_gen_mips64_entry_t));
91 } else if (type == PFMLIB_MIPS_ICE9B_PMU) {
92 gen_mips64_pe = gen_mips64_ice9b_pe;
93// core_counters = 2;
94 bound = (sizeof(gen_mips64_ice9b_pe)/sizeof(pme_gen_mips64_entry_t));
95 }
96
97 /* Allocate the table */
98
99 sicortex_pe = malloc(bound*sizeof(*sicortex_pe));
100 if (sicortex_pe == NULL)
101 return 0;
102
103 /* If we find we have SCB support */
104
106 {
107 /* Account for 4 sampling PMD registers */
110 }
111 else
112 {
114 /* Count up CPU only events */
115 for (i=0;i<bound;i++)
116 {
117 unsigned int tmp = gen_mips64_pe[i].pme_counters;
118 if (!(tmp & (1<<core_counters)))
120 }
121 }
122
123 for (i=0;i<bound;i++)
124 {
129 if (sicortex_pe[i].pme_counters & (1<<core_counters)) {
130 int j;
132 for (j=0;j<sicortex_pe[i].pme_numasks;j++)
133 {
137 }
138 } else {
140 memset(sicortex_pe[i].pme_umasks,0x0,sizeof(sicortex_pe[i].pme_umasks));
141 }
142 }
143 return 1;
144}
double tmp
int i
uint16_t type
#define PFMLIB_MIPS_ICE9B_PMU
Definition: pfmlib.h:255
#define PFMLIB_MIPS_ICE9A_PMU
Definition: pfmlib.h:254
static pme_gen_mips64_entry_t * gen_mips64_pe
#define MAX_ICE9_PMDS
#define core_counters
#define MAX_ICE9_PMCS
static pme_sicortex_entry_t * sicortex_pe
pfm_pmu_support_t sicortex_support
static pme_sicortex_umask_t sicortex_scb_umasks[PFMLIB_SICORTEX_MAX_UMASK]
#define PFMLIB_SICORTEX_MAX_UMASK
unsigned int pmc_count
Definition: pfmlib_priv.h:37
unsigned int num_cnt
Definition: pfmlib_priv.h:38
unsigned int pmd_count
Definition: pfmlib_priv.h:36
unsigned int pme_count
Definition: pfmlib_priv.h:35
char * pme_name
char * pme_desc
unsigned int pme_counters
unsigned int pme_code
unsigned int pme_numasks
char * pme_name
unsigned int pme_code
char * pme_desc
unsigned int pme_counters
pme_sicortex_umask_t pme_umasks[PFMLIB_SICORTEX_MAX_UMASK]
Here is the caller graph for this function:

◆ pfm_sicortex_detect()

static int pfm_sicortex_detect ( void  )
static

Definition at line 147 of file pfmlib_sicortex.c.

148{
149 static char mips_name[64] = "";
150 int ret;
151 char buffer[128];
153
154 ret = __pfm_getcpuinfo_attr("cpu model", buffer, sizeof(buffer));
155 if (ret == -1)
156 return PFMLIB_ERR_NOTSUPP;
157
159 if (strstr(buffer,"SiCortex ICE9A"))
160 {
162 return PFMLIB_ERR_NOTSUPP;
163 sicortex_support.pmu_name = mips_name;
164 strcpy(sicortex_support.pmu_name,"MIPSICE9A"),
166 }
167 else if (strstr(buffer,"SiCortex ICE9B"))
168 {
170 return PFMLIB_ERR_NOTSUPP;
171 sicortex_support.pmu_name = mips_name;
172 strcpy(sicortex_support.pmu_name,"MIPSICE9B"),
174 }
175 else
176 return PFMLIB_ERR_NOTSUPP;
177
178 if (sicortex_support.num_cnt == 0)
180
181 return PFMLIB_SUCCESS;
182}
#define PFMLIB_SUCCESS
Definition: pfmlib.h:283
#define PFMLIB_ERR_NOTSUPP
Definition: pfmlib.h:284
int __pfm_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen)
static int compute_ice9_counters(int type)
Here is the call graph for this function:

◆ pfm_sicortex_dispatch_counters()

static int pfm_sicortex_dispatch_counters ( pfmlib_input_param_t inp,
pfmlib_sicortex_input_param_t mod_in,
pfmlib_output_param_t outp 
)
static

Definition at line 357 of file pfmlib_sicortex.c.

358{
359 /* pfmlib_sicortex_input_param_t *param = mod_in; */
360 pfmlib_event_t *e = inp->pfp_events;
361 pfmlib_reg_t *pc, *pd;
362 unsigned int i, j, cnt = inp->pfp_event_count;
363 unsigned int used = 0;
365 unsigned int cntr, avail;
366
367 pc = outp->pfp_pmcs;
368 pd = outp->pfp_pmds;
369
370 /* Degree N rank based allocation */
372
373 if (PFMLIB_DEBUG()) {
374 for (j=0; j < cnt; j++) {
375 DPRINT("ev[%d]=%s, counters=0x%x\n", j, sicortex_pe[e[j].event].pme_name,sicortex_pe[e[j].event].pme_counters);
376 }
377 }
378
379 /* Do rank based allocation, counters that live on 1 reg
380 before counters that live on 2 regs etc. */
381
382 /* CPU counters first */
383 for (i=1;i<=core_counters;i++)
384 {
385 for (j=0; j < cnt;j++)
386 {
387 /* CPU counters first */
388 if ((sicortex_pe[e[j].event].pme_counters & ((1<<core_counters)-1)) && (pfmlib_popcnt(sicortex_pe[e[j].event].pme_counters) == i))
389 {
390 /* These counters can be used for this event */
391 avail = ~used & sicortex_pe[e[j].event].pme_counters;
392 DPRINT("Rank %d: Counters available 0x%x\n",i,avail);
393 if (avail == 0x0)
394 return PFMLIB_ERR_NOASSIGN;
395
396 /* Pick one, mark as used*/
397 cntr = ffs(avail) - 1;
398 DPRINT("Rank %d: Chose counter %d\n",i,cntr);
399
400 /* Update registers */
401 stuff_sicortex_regs(e,inp->pfp_dfl_plm,pc,pd,cntr,j,mod_in);
402
403 used |= (1 << cntr);
404 DPRINT("Rank %d: Used counters 0x%x\n",i, used);
405 }
406 }
407 }
408
409 /* SCB counters can live anywhere */
410
411 used = 0;
412 for (j=0; j < cnt;j++)
413 {
414 unsigned int cntr;
415
416 /* CPU counters first */
417 if (sicortex_pe[e[j].event].pme_counters & (1<<core_counters))
418 {
419 int k, has_ifother = 0, has_hist = 0;
420 for (k=0;k<e[j].num_masks;k++)
421 {
422 if ((e[j].unit_masks[k] == 0) || (e[j].unit_masks[k] == 1) || (e[j].unit_masks[k] == 2)) {
423 if (has_ifother)
424 return PFMLIB_ERR_UMASK;
425 has_ifother = 1;
426 }
427 else if ((e[j].unit_masks[k] == 3) || (e[j].unit_masks[k] == 4)) {
428 if (has_hist)
429 return PFMLIB_ERR_UMASK;
430 has_hist = 1;
431 }
432 }
433 /* These counters can be used for this event */
434 avail = sicortex_support.num_cnt - core_counters - used;
435 DPRINT("SCB(%d): Counters available %d\n",j,avail);
436
437 cntr = (sicortex_support.num_cnt - core_counters) - avail;
438 DPRINT("SCB(%d): Chose SCB counter %d\n",j,cntr);
439
440 /* Update registers */
441 stuff_sicortex_regs(e,inp->pfp_dfl_plm,pc,pd,cntr,j,mod_in);
442 used++;
443 DPRINT("SCB(%d): Used counters %d\n",j,used);
444 }
445 }
446 if (used)
447 {
448 outp->pfp_pmc_count = stuff_sicortex_scb_control_regs(pc,pd,cnt,mod_in);
449 outp->pfp_pmd_count = cnt;
450 return PFMLIB_SUCCESS;
451 }
452
453 /* number of evtsel registers programmed */
454 outp->pfp_pmc_count = cnt;
455 outp->pfp_pmd_count = cnt;
456
457 return PFMLIB_SUCCESS;
458}
#define PFMLIB_ERR_UMASK
Definition: pfmlib.h:306
#define PFMLIB_ERR_TOOMANY
Definition: pfmlib.h:295
#define PFMLIB_ERR_NOASSIGN
Definition: pfmlib.h:288
#define pfmlib_popcnt
#define DPRINT(fmt, a...)
Definition: pfmlib_priv.h:90
#define PFMLIB_DEBUG()
Definition: pfmlib_priv.h:76
static int stuff_sicortex_scb_control_regs(pfmlib_reg_t *pc, pfmlib_reg_t *pd, int num, pfmlib_sicortex_input_param_t *mod_in)
static void stuff_sicortex_regs(pfmlib_event_t *e, int plm, pfmlib_reg_t *pc, pfmlib_reg_t *pd, int cntr, int j, pfmlib_sicortex_input_param_t *mod_in)
unsigned int num_masks
Definition: pfmlib.h:90
unsigned int event
Definition: pfmlib.h:86
unsigned int pfp_dfl_plm
Definition: pfmlib.h:110
pfmlib_event_t pfp_events[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:113
unsigned int pfp_event_count
Definition: pfmlib.h:109
pfmlib_reg_t pfp_pmds[PFMLIB_MAX_PMDS]
Definition: pfmlib.h:130
pfmlib_reg_t pfp_pmcs[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:129
unsigned int pfp_pmc_count
Definition: pfmlib.h:127
unsigned int pfp_pmd_count
Definition: pfmlib.h:128
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_sicortex_dispatch_events()

static int pfm_sicortex_dispatch_events ( pfmlib_input_param_t inp,
void *  model_in,
pfmlib_output_param_t outp,
void *  model_out 
)
static

Definition at line 461 of file pfmlib_sicortex.c.

462{
464
465 return pfm_sicortex_dispatch_counters(inp, mod_sicortex_in, outp);
466}
static int pfm_sicortex_dispatch_counters(pfmlib_input_param_t *inp, pfmlib_sicortex_input_param_t *mod_in, pfmlib_output_param_t *outp)
Here is the call graph for this function:

◆ pfm_sicortex_get_cycle_event()

static int pfm_sicortex_get_cycle_event ( pfmlib_event_t e)
static

Definition at line 609 of file pfmlib_sicortex.c.

610{
611 return pfm_find_full_event("CPU_CYCLES",e);
612}
pfm_err_t pfm_find_full_event(const char *str, pfmlib_event_t *e)
Here is the call graph for this function:

◆ pfm_sicortex_get_event_code()

static int pfm_sicortex_get_event_code ( unsigned int  i,
unsigned int  cnt,
int code 
)
static

Definition at line 469 of file pfmlib_sicortex.c.

470{
472
473 /* check validity of counter index */
474 if (cnt != PFMLIB_CNT_FIRST) {
475 if (cnt < 0 || cnt >= sicortex_support.pmc_count)
476 return PFMLIB_ERR_INVAL; }
477 else {
478 cnt = ffs(sicortex_pe[i].pme_counters)-1;
479 if (cnt == -1)
480 return(PFMLIB_ERR_INVAL);
481 }
482
483 /* if cnt == 1, shift right by 0, if cnt == 2, shift right by 8 */
484 /* Works on both 5k anf 20K */
485
486 unsigned int tmp = sicortex_pe[i].pme_counters;
487 /* CPU event */
488 if (tmp & ((1<<core_counters)-1))
489 {
490 if (tmp & (1<< cnt))
491 *code = 0xff & (sicortex_pe[i].pme_code >> (cnt*8));
492 else
493 return PFMLIB_ERR_INVAL;
494 }
495 /* SCB event */
496 else
497 {
498 if ((cnt < 6) || (cnt >= sicortex_support.pmc_count))
499 return PFMLIB_ERR_INVAL;
500 *code = 0xffff & (sicortex_pe[i].pme_code >> 16);
501 }
502
503 return PFMLIB_SUCCESS;
504}
#define PFMLIB_ERR_INVAL
Definition: pfmlib.h:285
#define PFMLIB_CNT_FIRST
Definition: pfmlib_priv.h:62

◆ pfm_sicortex_get_event_counters()

static void pfm_sicortex_get_event_counters ( unsigned int  j,
pfmlib_regmask_t counters 
)
static

Definition at line 519 of file pfmlib_sicortex.c.

520{
522 unsigned int tmp;
523
524 memset(counters, 0, sizeof(*counters));
526
527 /* CPU counter */
528 if (tmp & ((1<<core_counters)-1))
529 {
530 while (tmp)
531 {
532 int t = ffs(tmp) - 1;
533 pfm_regmask_set(counters, t);
534 tmp = tmp ^ (1 << t);
535 }
536 }
537 /* SCB counter, requires first 4, then 1 of the remaining */
538 else
539 {
540 int i;
541 for (i=6;i<sicortex_support.pmc_count;i++)
542 pfm_regmask_set(counters, i);
543 }
544}
static int pfm_regmask_set(pfmlib_regmask_t *h, unsigned int b)
Definition: pfmlib.h:321
Here is the call graph for this function:

◆ pfm_sicortex_get_event_description()

static int pfm_sicortex_get_event_description ( unsigned int  ev,
char **  str 
)
static

Definition at line 596 of file pfmlib_sicortex.c.

597{
598 char *s;
599 s = sicortex_pe[ev].pme_desc;
600 if (s) {
601 *str = strdup(s);
602 } else {
603 *str = NULL;
604 }
605 return PFMLIB_SUCCESS;
606}
double s
Definition: byte_profile.c:36

◆ pfm_sicortex_get_event_mask_code()

static int pfm_sicortex_get_event_mask_code ( unsigned int  ev,
unsigned int  midx,
unsigned int code 
)
static

Definition at line 693 of file pfmlib_sicortex.c.

694{
695 *code = sicortex_pe[ev].pme_umasks[midx].pme_ucode;
696 return PFMLIB_SUCCESS;
697}

◆ pfm_sicortex_get_event_mask_desc()

static int pfm_sicortex_get_event_mask_desc ( unsigned int  ev,
unsigned int  midx,
char **  str 
)
static

Definition at line 673 of file pfmlib_sicortex.c.

674{
675 char *s;
676
677 s = sicortex_pe[ev].pme_umasks[midx].pme_udesc;
678 if (s) {
679 *str = strdup(s);
680 } else {
681 *str = NULL;
682 }
683 return PFMLIB_SUCCESS;
684}

◆ pfm_sicortex_get_event_mask_name()

static char * pfm_sicortex_get_event_mask_name ( unsigned int  ev,
unsigned int  midx 
)
static

Definition at line 667 of file pfmlib_sicortex.c.

668{
669 return sicortex_pe[ev].pme_umasks[midx].pme_uname;
670}

◆ pfm_sicortex_get_event_name()

static char * pfm_sicortex_get_event_name ( unsigned int  i)
static

Definition at line 590 of file pfmlib_sicortex.c.

591{
592 return sicortex_pe[i].pme_name;
593}

◆ pfm_sicortex_get_event_umask()

int pfm_sicortex_get_event_umask ( unsigned int  i,
unsigned long umask 
)

Definition at line 510 of file pfmlib_sicortex.c.

511{
513 if (i >= sicortex_support.pme_count || umask == NULL) return PFMLIB_ERR_INVAL;
514 *umask = 0; //evt_umask(i);
515 return PFMLIB_SUCCESS;
516}

◆ pfm_sicortex_get_hw_counter_width()

static void pfm_sicortex_get_hw_counter_width ( unsigned int width)
static

Definition at line 584 of file pfmlib_sicortex.c.

585{
587}
#define PMU_GEN_MIPS64_COUNTER_WIDTH

◆ pfm_sicortex_get_impl_counters()

static void pfm_sicortex_get_impl_counters ( pfmlib_regmask_t impl_counters)
static

Definition at line 567 of file pfmlib_sicortex.c.

568{
569 unsigned int i = 0;
571
572 pfm_regmask_set(impl_counters, 0);
573 pfm_regmask_set(impl_counters, 1);
574 /* If we have the SCB turned on */
576 {
577 /* counting pmds are not contiguous on ICE9*/
578 for(i=6; i < sicortex_support.pmd_count; i++)
579 pfm_regmask_set(impl_counters, i);
580 }
581}
Here is the call graph for this function:

◆ pfm_sicortex_get_impl_perfctr()

static void pfm_sicortex_get_impl_perfctr ( pfmlib_regmask_t impl_pmds)
static

Definition at line 557 of file pfmlib_sicortex.c.

558{
559 unsigned int i = 0;
561
562 /* all pmds are contiguous */
563 for(i=0; i < sicortex_support.pmd_count; i++) pfm_regmask_set(impl_pmds, i);
564}
Here is the call graph for this function:

◆ pfm_sicortex_get_impl_perfsel()

static void pfm_sicortex_get_impl_perfsel ( pfmlib_regmask_t impl_pmcs)
static

Definition at line 547 of file pfmlib_sicortex.c.

548{
549 unsigned int i = 0;
551
552 /* all pmcs are contiguous */
553 for(i=0; i < sicortex_support.pmc_count; i++) pfm_regmask_set(impl_pmcs, i);
554}
Here is the call graph for this function:

◆ pfm_sicortex_get_inst_retired()

static int pfm_sicortex_get_inst_retired ( pfmlib_event_t e)
static

Definition at line 615 of file pfmlib_sicortex.c.

616{
617 return pfm_find_full_event("CPU_INSEXEC",e);
618}
Here is the call graph for this function:

◆ pfm_sicortex_get_num_event_masks()

static unsigned int pfm_sicortex_get_num_event_masks ( unsigned int  ev)
static

Definition at line 687 of file pfmlib_sicortex.c.

688{
689 return sicortex_pe[ev].pme_numasks;
690}

◆ pfm_sicortex_has_umask_default()

static int pfm_sicortex_has_umask_default ( unsigned int  ev)
static

Definition at line 700 of file pfmlib_sicortex.c.

701{
702 /* all events have default unit mask */
703 return 1;
704}

◆ pfm_sicortex_is_cpu()

int pfm_sicortex_is_cpu ( unsigned int  i)

Definition at line 623 of file pfmlib_sicortex.c.

624{
626 {
627 unsigned int tmp = sicortex_pe[i].pme_counters;
628 return !(tmp & (1<<core_counters));
629 }
630 return 0;
631}

◆ pfm_sicortex_is_scb()

int pfm_sicortex_is_scb ( unsigned int  i)

Definition at line 634 of file pfmlib_sicortex.c.

635{
637 {
638 unsigned int tmp = sicortex_pe[i].pme_counters;
639 return (tmp & (1<<core_counters));
640 }
641 return 0;
642}

◆ pfm_sicortex_support_domain()

int pfm_sicortex_support_domain ( unsigned int  i)

Definition at line 645 of file pfmlib_sicortex.c.

646{
648 {
649 unsigned int tmp = sicortex_pe[i].pme_counters;
650 return (tmp & (1<<3));
651 }
652 return 0;
653}

◆ pfm_sicortex_support_vpc_pea()

int pfm_sicortex_support_vpc_pea ( unsigned int  i)

Definition at line 656 of file pfmlib_sicortex.c.

657{
659 {
660 unsigned int tmp = sicortex_pe[i].pme_counters;
661 return (tmp & (1<<4));
662 }
663 return 0;
664}

◆ stuff_sicortex_regs()

static void stuff_sicortex_regs ( pfmlib_event_t e,
int  plm,
pfmlib_reg_t pc,
pfmlib_reg_t pd,
int  cntr,
int  j,
pfmlib_sicortex_input_param_t mod_in 
)
static

Definition at line 184 of file pfmlib_sicortex.c.

185{
187 reg.val = 0; /* assume reserved bits are zerooed */
188 /* if plm is 0, then assume not specified per-event and use default */
189 plm = e[j].plm ? e[j].plm : plm;
190 reg.sel_usr = plm & PFM_PLM3 ? 1 : 0;
191 reg.sel_os = plm & PFM_PLM0 ? 1 : 0;
192 reg.sel_sup = plm & PFM_PLM1 ? 1 : 0;
193 reg.sel_exl = plm & PFM_PLM2 ? 1 : 0;
194 reg.sel_int = 1; /* force int to 1 */
195
196 /* CPU event */
197 if (sicortex_pe[e[j].event].pme_counters & ((1<<core_counters)-1))
198 {
199 reg.sel_event_mask = (sicortex_pe[e[j].event].pme_code >> (cntr*8)) & 0xff;
200 pc[j].reg_addr = cntr*2;
201 pc[j].reg_value = reg.val;
202 pc[j].reg_num = cntr;
203
204 __pfm_vbprintf("[CP0_25_%u(pmc%u)=0x%"PRIx64" event_mask=0x%x usr=%d os=%d sup=%d exl=%d int=1] %s\n",
205 pc[j].reg_addr,
206 pc[j].reg_num,
207 pc[j].reg_value,
208 reg.sel_event_mask,
209 reg.sel_usr,
210 reg.sel_os,
211 reg.sel_sup,
212 reg.sel_exl,
213 sicortex_pe[e[j].event].pme_name);
214
215 pd[j].reg_num = cntr;
216 pd[j].reg_addr = cntr*2 + 1;
217
218 __pfm_vbprintf("[CP0_25_%u(pmd%u)]\n",
219 pc[j].reg_addr,
220 pc[j].reg_num);
221
222 }
223 /* SCB event */
224 else
225 {
227 int k;
228 scbreg.val = 0;
230 for (k=0;k<e[j].num_masks;k++)
231 {
232 if (e[j].unit_masks[k] == 4)
233 scbreg.sicortex_ScbPerfBucket_reg.hist = 0x1;
234 else if (e[j].unit_masks[k] == 1)
236 else if (e[j].unit_masks[k] == 2)
238 }
239 __pfm_vbprintf("[ScbPerfBucket[%u](pmc%u)=0x%"PRIx64" event=0x%x hist=%d ifOther=0x%x]\n",
240 cntr,cntr+6,scbreg.val,
244
245 pc[j].reg_addr = cntr;
246 pc[j].reg_value = scbreg.val;
247 pc[j].reg_num = cntr + 6;
248
249 pd[j].reg_addr = cntr;
250 pd[j].reg_num = cntr + 6;
251
252 __pfm_vbprintf("[ScbPerfCount[%u](pmd%u)]\n",
253 pc[j].reg_addr,
254 pc[j].reg_num);
255
256 }
257}
#define PFM_PLM2
Definition: pfmlib.h:52
#define PFM_PLM3
Definition: pfmlib.h:53
#define PFM_PLM0
Definition: pfmlib.h:50
#define PFM_PLM1
Definition: pfmlib.h:51
void __pfm_vbprintf(const char *fmt,...)
Definition: pfmlib_priv.c:52
unsigned int plm
Definition: pfmlib.h:87
unsigned long long reg_value
Definition: pfmlib.h:98
unsigned int reg_num
Definition: pfmlib.h:100
unsigned long long reg_addr
Definition: pfmlib.h:99
unsigned long sel_event_mask
struct pmc_sicortex_scb_reg_t::@92 sicortex_ScbPerfBucket_reg
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stuff_sicortex_scb_control_regs()

static int stuff_sicortex_scb_control_regs ( pfmlib_reg_t pc,
pfmlib_reg_t pd,
int  num,
pfmlib_sicortex_input_param_t mod_in 
)
static

Definition at line 259 of file pfmlib_sicortex.c.

260{
265
266 // __pfm_vbprintf("num = %d\n",num);
267
268 /* The kernel will enforce most of these, see perfmon_ice9.c in the kernel */
269
270 /* ScbPerfCtl */
271
272 pc[num].reg_num = 2;
273 pc[num].reg_addr = 2;
274 two.val = 0;
275 if (mod_in && (mod_in->flags & PFMLIB_SICORTEX_INPUT_SCB_INTERVAL))
276 {
278 }
279 else
280 {
281 two.sicortex_ScbPerfCtl_reg.Interval = 6; /* 2048 cycles */
282 }
283 if (mod_in && (mod_in->flags & PFMLIB_SICORTEX_INPUT_SCB_NOINC))
284 {
286 }
287 else
288 {
290 }
291
292 two.sicortex_ScbPerfCtl_reg.IntBit = 31; /* Interrupt on last bit */
295
296 __pfm_vbprintf("[Scb%s(pmc%u)=0x%"PRIx64" Interval=0x%x IntBit=0x%x NoInc=%d AddrAssert=%d MagicEvent=0x%x]\n","PerfCtl",
297 pc[num].reg_num,
298 two.val,
304 pc[num].reg_value = two.val;
305
306 /*ScbPerfHist */
307
308 pc[++num].reg_num = 3;
309 pc[num].reg_addr = 3;
310 three.val = 0;
311 if (mod_in && (mod_in->flags & PFMLIB_SICORTEX_INPUT_SCB_HISTGTE))
313 else
315
316 __pfm_vbprintf("[Scb%s(pmc%u)=0x%"PRIx64" HistGte=0x%x]\n","PerfHist",
317 pc[num].reg_num,
318 three.val,
320 pc[num].reg_value = three.val;
321
322 /*ScbPerfBuckNum */
323
324 pc[++num].reg_num = 4;
325 pc[num].reg_addr = 4;
326 four.val = 0;
327 if (mod_in && (mod_in->flags & PFMLIB_SICORTEX_INPUT_SCB_BUCKET))
329 else
331 __pfm_vbprintf("[Scb%s(pmc%u)=0x%"PRIx64" Bucket=0x%x]\n","PerfBuckNum",
332 pc[num].reg_num,
333 four.val,
335 pc[num].reg_value = four.val;
336
337 /*ScbPerfEna */
338
339 pc[++num].reg_num = 5;
340 pc[num].reg_addr = 5;
341 five.val = 0;
343 __pfm_vbprintf("[Scb%s(pmc%u)=0x%"PRIx64" ena=%d]\n","PerfEna",
344 pc[num].reg_num,
345 five.val,
347 pc[num].reg_value = five.val;
348 ++num;
349 return(num);
350}
#define PFMLIB_SICORTEX_INPUT_SCB_NOINC
#define PFMLIB_SICORTEX_INPUT_SCB_INTERVAL
#define PFMLIB_SICORTEX_INPUT_SCB_HISTGTE
#define PFMLIB_SICORTEX_INPUT_SCB_BUCKET
pfmlib_sicortex_scb_t pfp_sicortex_scb_global
struct pmc_sicortex_scb_reg_t::@89 sicortex_ScbPerfHist_reg
unsigned long MagicEvent
struct pmc_sicortex_scb_reg_t::@91 sicortex_ScbPerfEna_reg
unsigned long AddrAssert
struct pmc_sicortex_scb_reg_t::@88 sicortex_ScbPerfCtl_reg
struct pmc_sicortex_scb_reg_t::@90 sicortex_ScbPerfBuckNum_reg
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ sicortex_pe

pme_sicortex_entry_t* sicortex_pe = NULL
static

Definition at line 54 of file pfmlib_sicortex.c.

◆ sicortex_support

pfm_pmu_support_t sicortex_support
Initial value:
= {
.pmu_name = NULL,
.pmu_type = PFMLIB_UNKNOWN_PMU,
.pme_count = 0,
.pmc_count = 0,
.pmd_count = 0,
.num_cnt = 0,
.get_event_code = pfm_sicortex_get_event_code,
.get_event_name = pfm_sicortex_get_event_name,
.get_event_counters = pfm_sicortex_get_event_counters,
.dispatch_events = pfm_sicortex_dispatch_events,
.pmu_detect = pfm_sicortex_detect,
.get_impl_counters = pfm_sicortex_get_impl_counters,
.get_hw_counter_width = pfm_sicortex_get_hw_counter_width,
.get_num_event_masks = pfm_sicortex_get_num_event_masks,
.get_event_mask_name = pfm_sicortex_get_event_mask_name,
.get_event_mask_code = pfm_sicortex_get_event_mask_code,
.get_event_mask_desc = pfm_sicortex_get_event_mask_desc,
.get_cycle_event = pfm_sicortex_get_cycle_event,
.get_inst_retired_event = pfm_sicortex_get_inst_retired,
.has_umask_default = pfm_sicortex_has_umask_default
}
#define PFMLIB_UNKNOWN_PMU
Definition: pfmlib.h:222
#define PFMLIB_MULT_CODE_EVENT
Definition: pfmlib_priv.h:60
static int pfm_sicortex_get_event_mask_code(unsigned int ev, unsigned int midx, unsigned int *code)
static int pfm_sicortex_get_cycle_event(pfmlib_event_t *e)
static int pfm_sicortex_has_umask_default(unsigned int ev)
static unsigned int pfm_sicortex_get_num_event_masks(unsigned int ev)
static void pfm_sicortex_get_impl_perfsel(pfmlib_regmask_t *impl_pmcs)
static int pfm_sicortex_get_event_mask_desc(unsigned int ev, unsigned int midx, char **str)
static int pfm_sicortex_get_inst_retired(pfmlib_event_t *e)
static void pfm_sicortex_get_hw_counter_width(unsigned int *width)
static int pfm_sicortex_dispatch_events(pfmlib_input_param_t *inp, void *model_in, pfmlib_output_param_t *outp, void *model_out)
static int pfm_sicortex_get_event_description(unsigned int ev, char **str)
static int pfm_sicortex_get_event_code(unsigned int i, unsigned int cnt, int *code)
static int pfm_sicortex_detect(void)
static void pfm_sicortex_get_event_counters(unsigned int j, pfmlib_regmask_t *counters)
static void pfm_sicortex_get_impl_counters(pfmlib_regmask_t *impl_counters)
static char * pfm_sicortex_get_event_mask_name(unsigned int ev, unsigned int midx)
static char * pfm_sicortex_get_event_name(unsigned int i)
static void pfm_sicortex_get_impl_perfctr(pfmlib_regmask_t *impl_pmds)

Definition at line 706 of file pfmlib_sicortex.c.