1.If config event is PERF_EVENT_TYPE_HW, then map it to the real eventId first, otherwise use the configured eventId directly. 2.Find available counter for each event. 3.Decide whether this hardware pmu need prescaler (once every 64 cycle counts).
62 if (cycleCode == PERF_HW_INVALID_EVENT_TYPE) {
69 for (i = 0; i < eventNum; i++) {
72 if (!VALID_PERIOD(event->period)) {
73 PRINT_ERR(
"Config period: 0x%x invalid, should be in (%#x, %#x)\n", event->period,
74 PERIOD_CALC(CCNT_PERIOD_UPPER_BOUND), PERIOD_CALC(CCNT_PERIOD_LOWER_BOUND));
79 UINT32 eventId = armPmu->
mapEvent(event->eventId, PERF_EVENT_TO_CODE);
80 if (eventId == PERF_HW_INVALID_EVENT_TYPE) {
83 event->eventId = eventId;
86 if (event->eventId == cycleCode) {
87 event->counter = cycleCounter;
89 event->counter = counter;
93 if (counter >= maxCounter) {
94 PRINT_ERR(
"max events: %u excluding cycle event\n", maxCounter - 1);
98 PRINT_DEBUG(
"Perf Config %u eventId = 0x%x, counter = 0x%x, period = 0x%x\n", i, event->eventId, event->counter,
UINT32 OsGetPmuMaxCounter(VOID)
UINT32 OsGetPmuCounter0(VOID)
UINT32 OsGetPmuCycleCounter(VOID)
@ PERF_COUNT_HW_CPU_CYCLES
Event per[PERF_MAX_EVENT]