📄 ixperfprofaccxscalepmu.c
字号:
ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_CLK_CTR_ID]); /*no event counting, write default value to all event ctrs to save power*/ _ixPerfProfAccXscalePmuEvtSelectWrite(IX_PERFPROF_ACC_XSCALE_PMU_CLK_CTR); timeSampStarted = TRUE; /*set to show that this process has been started*/ return IX_PERFPROF_ACC_STATUS_SUCCESS;}PUBLIC IxPerfProfAccStatusixPerfProfAccXscalePmuTimeSampStop( IxPerfProfAccXscalePmuEvtCnt *clkCount, IxPerfProfAccXscalePmuSamplePcProfile *timeProfile){ UINT32 i; UINT32 samples;#ifdef __vxworks char symbolName[IX_PERFPROF_ACC_XSCALE_PMU_SYMBOL_SIZE]; /* Location where the symbol name from search will be stored */ int symbolValue; /* Location where the correct symbol address is stored */ SYM_TYPE pointerType; FILE *fpTimeSampResults; /* Pointer to output file */ float percentage;#endif /*check whether ixPerfProfAccXscalePmuTimeSampStart() has been called*/ if (!timeSampStarted) { return IX_PERFPROF_ACC_STATUS_XSCALE_PMU_START_NOT_CALLED; } /*error check the parameter*/ if (NULL == clkCount) { /* report the error */ IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixPerfProfAccXscalePmuTimeSampStop - clkCount is invalid\n", 0, 0, 0, 0, 0, 0); /* return error */ return IX_PERFPROF_ACC_STATUS_FAIL; } /*error check the parameter*/ if (NULL == timeProfile) { /* report the error */ IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixPerfProfAccXscalePmuTimeSampStop - timeProfile is invalid\n", 0, 0, 0, 0, 0, 0); /* return error */ return IX_PERFPROF_ACC_STATUS_FAIL; } /*disable all interrupts to stop counting*/ ixPerfProfAccXscalePmuIntrDisable(); /*get the final clock count and number of samples taken*/ ixPerfProfAccXscalePmuClkCntGet (clkCount); /*construct profiling summary*/ for (i=0; i<ctrSamples[IX_PERFPROF_ACC_XSCALE_PMU_CLK_CTR_ID]; i++) { ixPerfProfAccXscalePmuProfileConstruct (clkCtrArray[i], timeProfile); }/*end of for ctrSamples[IX_PERFPROF_ACC_XSCALE_PMU_CLK_CTR_ID]*/ timeSampStarted = FALSE; /*reset flag as time sampling has ended*/ /*call unlock because process has ended*/ ixPerfProfAccUnlock(); ixPerfProfAccXscalePmuProfileSort(timeProfile, clkCount->upper32BitsEventCount); #ifdef __vxworks /* Create file called timeSampleResults.txt */ fpTimeSampResults = fopen("timeSampleResults.txt","w"); /* Check if fopen is successful. If not, log message */ if(NULL == fpTimeSampResults) { IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_WARNING, IX_OSAL_LOG_DEV_STDOUT, "*** Warning: Time Sampling Results file could not be generated.\n\n", 0,0, 0, 0, 0, 0); } else { /* print table header to file */ fprintf(fpTimeSampResults,"Total Number of samples = %u\n\n\n", clkCount->upper32BitsEventCount); fprintf(fpTimeSampResults,"Hits Percent PC Address Symbol Address Offset ClosestRoutine\n"); fprintf(fpTimeSampResults,"------- ------- ---------- -------------- ------ --------------\n"); /* Find symbol names for PC address and write values to file */ for (samples = 0; samples < IX_PERFPROF_ACC_XSCALE_PMU_MAX_PROFILE_SAMPLES; samples++) { if(timeProfile[samples].freq > 0) { symFindByValue (sysSymTbl, timeProfile[samples].programCounter, symbolName, &symbolValue, &pointerType); percentage=((float)timeProfile[samples].freq/ (float)clkCount->upper32BitsEventCount)*100; fprintf (fpTimeSampResults,"%7u %7.4f %10x %14x %6x %s\n", timeProfile[samples].freq, percentage, timeProfile[samples].programCounter, symbolValue, timeProfile[samples].programCounter - symbolValue, symbolName); } else { break; } } /* Close pointer to output file */ fclose(fpTimeSampResults); }/* if - else NULL == fpTimeSampResults */ /* For Linux copy results to global variable */ #elif defined (__linux) for (samples = 0; samples < clkCount->upper32BitsEventCount; samples++) { timeSampProfile[samples] = timeProfile[samples]; } #endif return IX_PERFPROF_ACC_STATUS_SUCCESS;}PUBLIC IxPerfProfAccStatusixPerfProfAccXscalePmuEventSampStart( UINT32 numEvents, IxPerfProfAccXscalePmuEvent pmuEvent1, UINT32 eventRate1, IxPerfProfAccXscalePmuEvent pmuEvent2, UINT32 eventRate2, IxPerfProfAccXscalePmuEvent pmuEvent3, UINT32 eventRate3, IxPerfProfAccXscalePmuEvent pmuEvent4, UINT32 eventRate4){ UINT32 i; IxPerfProfAccStatus status = IX_PERFPROF_ACC_STATUS_SUCCESS; IxFeatureCtrlDeviceId deviceType = IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X; deviceType = ixFeatureCtrlDeviceRead (); if(IX_FEATURE_CTRL_DEVICE_TYPE_IXP46X == deviceType) { IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixPerfProfAcc - This PPU component is not supported\n", 0, 0, 0, 0, 0, 0); return IX_PERFPROF_ACC_STATUS_COMPONENT_NOT_SUPPORTED; } /*check if any other util is currently running*/ status = ixPerfProfAccLock(); if (IX_PERFPROF_ACC_STATUS_ANOTHER_UTIL_IN_PROGRESS == status) { IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "Another utility is running\n", 0,0, 0, 0, 0, 0); return status; } /*check validity of input parameters*/ if ((IX_PERFPROF_ACC_XSCALE_PMU_MAX_EVENTS < numEvents) || (0 == numEvents)) { IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "range of numEvents is between 1 and 4\n", 0,0, 0, 0, 0, 0); ixPerfProfAccUnlock(); /*call unlock; process has been terminated*/ return IX_PERFPROF_ACC_STATUS_XSCALE_PMU_NUM_INVALID; }/*end of if numEvents*/ if((IX_PERFPROF_ACC_XSCALE_PMU_EVENT_MAX < pmuEvent1) || (IX_PERFPROF_ACC_XSCALE_PMU_EVENT_MAX < pmuEvent2) || (IX_PERFPROF_ACC_XSCALE_PMU_EVENT_MAX < pmuEvent3) || (IX_PERFPROF_ACC_XSCALE_PMU_EVENT_MAX < pmuEvent4)) { IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "value of event type entered is out of bounds\n", 0,0, 0, 0, 0, 0); ixPerfProfAccUnlock(); /*call unlock; process has been terminated*/ return IX_PERFPROF_ACC_STATUS_XSCALE_PMU_EVENT_INVALID; }/*end of if pmuEvent*/ numberEvents = numEvents; /*initialize globals*/ ctrSamples[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR1_ID] = 0; ctrSamples[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR2_ID] = 0; ctrSamples[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR3_ID] = 0; ctrSamples[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR4_ID] = 0; eventCounting = FALSE; /* set ctr base values * First initialize all to zero. Then set to the right value as requested by *users. The start value is MAX (0xFFFFFFFF) minus eventRate. The result is *exactly eventRate away from overflow. */ ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_CLK_CTR_ID] = 0; ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR1_ID] = 0; ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR2_ID] = 0; ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR3_ID] = 0; ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR4_ID] = 0; /* If user does not select zero, then we need to set the start based to *MAX (0xFFFFFFFF) minus eventRate */ if (0 != eventRate1)/*if rate is zero, that is base*/ { ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR1_ID] = IX_PERFPROF_ACC_XSCALE_PMU_MAX_COUNTER_VALUE - eventRate1; } if (0 != eventRate2)/*if rate is zero, that is base*/ { ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR2_ID] = IX_PERFPROF_ACC_XSCALE_PMU_MAX_COUNTER_VALUE - eventRate2; } if (0 != eventRate3)/*if rate is zero, that is base*/ { ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR3_ID] = IX_PERFPROF_ACC_XSCALE_PMU_MAX_COUNTER_VALUE - eventRate3; } if (0 != eventRate4)/*if rate is zero, that is base*/ { ctrBase[IX_PERFPROF_ACC_XSCALE_PMU_EVT_CTR4_ID] = IX_PERFPROF_ACC_XSCALE_PMU_MAX_COUNTER_VALUE - eventRate4; } /*initialize interrupt status for all counters*/ for (i=0;i<IX_PERFPROF_ACC_XSCALE_PMU_MAX_EVENTS;i++) { IxPerfProfAccXscalePmuIntrStatus[i] = FALSE; }/*end of for loop*/ /*bind interrupt to handler*/ ixPerfProfAccXscalePmuIntrConnect(); /*assign the appropriate events to each event counter*/ ixPerfProfAccXscalePmuEventSelect ( pmuEvent1, pmuEvent2, pmuEvent3, pmuEvent4); /* Clear all evt ctr bits in overflow flag register*/ _ixPerfProfAccXscalePmuOverFlowWrite( IX_PERFPROF_ACC_XSCALE_PMU_OFLOW_FLAG_PMN); /*write pmu interrupt enable register-no clk counting, and clk ctr is off*/ ixPerfProfAccXscalePmuIntrEnable(FALSE); /*Configure Performance Monitor Control Register - enable all counters, * reset event counters, no clock divider */ ixPerfProfAccXscalePmuCtrEnableReset ( FALSE, TRUE, FALSE, TRUE); /*enable BSP interrupt*/ ixPerfProfAccXscalePmuBspIntrEnable(); /*initialize event ctrs to base value*/ status = ixPerfProfAccXscalePmuEvtCtrInit(); if (status == IX_PERFPROF_ACC_STATUS_FAIL) { /*error due to num events out of bounds*/ IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_WARNING, IX_OSAL_LOG_DEV_STDOUT, "Warning: error initializing event counter\n", 0,0, 0, 0, 0, 0); ixPerfProfAccUnlock(); /*call unlock; process has been terminated*/ } /*end of if status*/ eventSampStarted = TRUE; /*set to show that this process has been started*/ return status;}PUBLIC IxPerfProfAccStatusixPerfProfAccXscalePmuEventSampStop( IxPerfProfAccXscalePmuSamplePcProfile *eventProfile1, IxPerfProfAccXscalePmuSamplePcProfile *eventProfile2, IxPerfProfAccXscalePmuSamplePcProfile *eventProfile3, IxPerfProfAccXscalePmuSamplePcProfile *eventProfile4){ UINT32 i; UINT32 j; UINT32 samples; IxPerfProfAccXscalePmuResults eventSampResults; #ifdef __vxworks char symbolName[IX_PERFPROF_ACC_XSCALE_PMU_SYMBOL_SIZE]; /* Location where symbold name for pc addr is stored */ int symbolValue; /* Location where correct pc addr is stored */ SYM_TYPE pointerType; FILE *fpEventSampResults; /* Pointer to results output file */ float percentage; #endif /*check whether ixPerfProfAccXscalePmuTimeSampStart() has been called*/ if (!eventSampStarted) { return IX_PERFPROF_ACC_STATUS_XSCALE_PMU_START_NOT_CALLED; } /*error check the parameter*/ if (NULL == eventProfile1) { /* report the error */ IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixPerfProfAccXscalePmuEventSampStop - eventProfile1 is invalid\n", 0, 0, 0, 0, 0, 0); /* return error */ return IX_PERFPROF_ACC_STATUS_FAIL; } /*error check the parameter*/ if (NULL == eventProfile2) { /* report the error */ IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixPerfProfAccXscalePmuEventSampStop - eventProfile2 is invalid\n", 0, 0, 0, 0, 0, 0); /* return error */ return IX_PERFPROF_ACC_STATUS_FAIL; } /*error check the parameter*/ if (NULL == eventProfile3) { /* report the error */ IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixPerfProfAccXscalePmuEventSampStop - eventProfile3 is invalid\n", 0, 0, 0, 0, 0, 0); /* return error */ return IX_PERFPROF_ACC_STATUS_FAIL; } /*error check the parameter*/ if (NULL == eventProfile4) { /* report the error */ IX_PERFPROF_ACC_LOG( IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixPerfProfAccXscalePmuEventSampStop - eventProfile4 is invalid\n", 0, 0, 0, 0, 0, 0); /* return error */ return IX_PERFPROF_ACC_STATUS_FAIL; } /*disable all interrupts to stop counting*/ ixPerfProfAccXscalePmuIntrDisable(); /*construct profiling summary*/ for (i=0; i<IX_PERFPROF_ACC_XSCALE_PMU_MAX_EVENTS; i++) { sumLen = 0; switch(i) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -