📄 ixdmaacccodelet.c
字号:
printf ("%02x ", (UINT32) ixDmaAccCodeletSrcBlock[i]); /* Show raw memory byte */ } /* Invalidate cache for destination block before a read access to ensure consistency */ IX_OSAL_CACHE_INVALIDATE(ixDmaAccCodeletDestBlock,IX_DMA_CODELET_MEMDUMPSIZE); /* Show memory dump for destination test array */ for(i = 0; i < IX_DMA_CODELET_MEMDUMPSIZE; i++) { if ( i%16 == 0 ) /* Show newline and address for every 16 bytes */ { printf ("\n Dst Addr %02x : ", (UINT32) &ixDmaAccCodeletDestBlock[i]); } printf ("%02x ", (UINT32) ixDmaAccCodeletDestBlock[i]); /* Show raw memory byte */ } printf ("\n"); return;}/* * Function definition : ixDmaAccCodeletCallback() * See header file for documentation. */voidixDmaAccCodeletCallback(IX_STATUS status){ /* Stop the time */ ixDmaAccCodeletTimeStore.stopTime[ixDmaAccCodeletLoopCount] = ixOsalTimestampGet(); /* Set the CallBack return flag to true */ ixDmaAccCodeletCallBackReturnFlag = TRUE; /* Set the CallBackStatus */ ixDmaAccCodeletCallBackStatus = status; return;}/* * Function definition : ixDmaAccCodeletTestPatternReset() * See header file for documentation. */PRIVATE void ixDmaAccCodeletTestPatternReset(void){ /* Counter for Test For-Loops */ UINT32 i,j; /* Test pattern is loaded into a temporary array here */ UINT8 testPattern[IX_DMA_CODELET_TESTPATTERN_LENGTH] = IX_DMA_CODELET_TESTPATTERN_LIST; /* Initialise the values in the Source Array */ for ( i = 0; i < IX_DMA_CODELET_TEST_MAXLENGTH; i += IX_DMA_CODELET_TESTPATTERN_LENGTH) { for ( j = 0; j < IX_DMA_CODELET_TESTPATTERN_LENGTH; j += 1) { ixDmaAccCodeletSrcBlock[i+j] = testPattern[j]; } } /* Flush the cache before performing a write to memory block */ IX_OSAL_CACHE_FLUSH(ixDmaAccCodeletSrcBlock,IX_DMA_CODELET_TESTPATTERN_LENGTH); /* Initialise the values in the Destination Array */ ixOsalMemSet( ixDmaAccCodeletDestBlock, 0xFF, IX_DMA_CODELET_TEST_MAXLENGTH); /* Flush the cache before performing a write to memory block */ IX_OSAL_CACHE_FLUSH(ixDmaAccCodeletDestBlock,IX_DMA_CODELET_TESTPATTERN_LENGTH); return;}/* * Function definition: ixDmaAccCodeletReportAverageTime() * It is used to calculate and display the average time for * PERFORMANCE_NUM_LOOP (i.e. 100 runs) */ PRIVATE void ixDmaAccCodeletReportAverageTime(UINT16 tLength){ UINT32 temp_count = 0; UINT32 diffTime = 0; UINT32 averageTick=0; UINT32 stopTime; UINT32 startTime; for(temp_count=0;temp_count < PERFORMANCE_LOOP_NUM; temp_count++) { stopTime = ixDmaAccCodeletTimeStore.stopTime[temp_count]; startTime = ixDmaAccCodeletTimeStore.startTime[temp_count]; /* Check if the timer wrap over */ if (stopTime < startTime) { diffTime = (0xffffffff - stopTime + startTime); } else { diffTime = stopTime-startTime; } averageTick = averageTick + diffTime; } averageTick = (averageTick/PERFORMANCE_LOOP_NUM) / IX_DMA_CODELET_XSCALE_TICK; printf ("\nAverage Rate (in Mbps) : "); ratioPrintf (IX_DMA_CODELET_DECIMAL_POINT, tLength*IX_DMA_CODELET_EIGHT_BITS, averageTick); printf ("\n===============================================\n\n"); return;}/* * Function definition: ratioPrintf () * It is used to display the ratio between two parameters */ PRIVATE void ratioPrintf (int decimalPoint, UINT64 param1, UINT64 param2){ UINT64 number = param1 / param2; unsigned char tempStr[30]; unsigned char *pStr = &tempStr[29]; int count = 0; *pStr = 0; while (number != 0) { count++; *(--pStr) = (number % 10) + '0'; number /= 10; } if (*pStr == 0) { count++; *(--pStr) = '0'; } while (count < 10) { count++; *(--pStr) = ' '; } printf ("%s.", pStr); param1 %= param2; while (decimalPoint-- != 0) { param1 *= 10; printf ("%d", (unsigned int) (param1 / param2)); param1 %= param2; }}/* * Function definition : ixDmaAccCodeletTestPerform() * See header file for documentation. */IX_STATUS ixDmaAccCodeletTestPerform( UINT16 transferLength, IxDmaTransferMode transferMode, IxDmaAddressingMode addressingMode, IxDmaTransferWidth transferWidth){ UINT32 transferCounter; UINT32 counterTimeOut = 0; IX_STATUS retval; /* Initialise Source Address to ixDmaAccCodeletSrcBlock */ UINT32 sourceAddr = (UINT32) ixDmaAccCodeletSrcBlock; /* Initialise Destination Address to ixDmaAccCodeletDestBlock */ UINT32 destinationAddr = (UINT32) ixDmaAccCodeletDestBlock; /* Initialise Test Patterns */ ixDmaAccCodeletTestPatternReset(); printf ("\nTransferred %d times with the following parameters", PERFORMANCE_LOOP_NUM); printf ("\nSource Address : 0x%x", sourceAddr); printf ("\nDestination Address : 0x%x", destinationAddr); printf ("\nTransfer Length : %d", transferLength); printf ("\nTransfer Mode : %s", ixDmaAccCodeletMsgTM[transferMode]); printf ("\nAddressing Mode : %s", ixDmaAccCodeletMsgAM[addressingMode]); printf ("\nTransfer Width : %s", ixDmaAccCodeletMsgTW[transferWidth]); printf ("\n\n%d byte memory dump before transfer :", IX_DMA_CODELET_MEMDUMPSIZE ); /* Show memory dump before transfer */ ixDmaAccCodeletShow(); /* Do Dma transfer for PERFORMANCE_NUM_LOOP (i.e. 100 runs) for each different type of configuration */ for (transferCounter = 0; transferCounter < PERFORMANCE_LOOP_NUM; transferCounter++) { /* Initialise Test Patterns */ ixDmaAccCodeletTestPatternReset(); ixDmaAccCodeletLoopCount = transferCounter; ixDmaAccCodeletTimeStore.startTime[transferCounter] = ixOsalTimestampGet(); /* Perform Dma Transfer */ /* Callback function will update the status and CallBackReturn flag */ retval = ixDmaAccDmaTransfer( (IxDmaAccDmaCompleteCallback) ixDmaAccCodeletCallback, sourceAddr, destinationAddr, transferLength, transferMode, addressingMode, transferWidth ); /* Go into while loop if FIFO FULL happens */ while (IX_DMA_REQUEST_FIFO_FULL == retval) { printf ("\nFIFO is FULL. Going to sleep mode "); /*Delay in 1 MSecond before Dma Request Q recovers */ ixOsalSleep(IX_CLIENT_SLEEP_IN_MS); counterTimeOut++; if (IX_DMA_CODELET_MAX_TIME_OUT == counterTimeOut) { /* Stop the operation and return fail */ printf("\nTime out on FIFO full"); return IX_FAIL; } /* Retransmit after 1ms */ retval = ixDmaAccDmaTransfer( (IxDmaAccDmaCompleteCallback) ixDmaAccCodeletCallback, sourceAddr, destinationAddr, transferLength, transferMode, addressingMode, transferWidth ); } /* If retval is not successful returns failure */ if (IX_DMA_SUCCESS != retval) { printf("\nDma Transfer fail"); return IX_FAIL; } /* set to 0 used for callback return count time out */ counterTimeOut = 0; /* Wait for callback to return */ while (!ixDmaAccCodeletCallBackReturnFlag) { /*wait until current transfer complete */ ixOsalSleep(IX_CLIENT_SLEEP_IN_MS); counterTimeOut++; if (IX_DMA_CODELET_MAX_TIME_OUT == counterTimeOut) { /* Stop the operation and return fail */ printf("\nTime out on callback"); return IX_FAIL; } } /* set counter to 0 so that it will be used by the next iteration */ counterTimeOut = 0; /* When callback is returned, set flag to false */ ixDmaAccCodeletCallBackReturnFlag = FALSE; }/* End of for-loop for transfer counter*/ /* At the end of 100 runs and after callback returned successfully then do show here */ if (IX_SUCCESS == ixDmaAccCodeletCallBackStatus) { printf ("\n\n%d byte memory dump after transfer :", IX_DMA_CODELET_MEMDUMPSIZE ); /* Memory dump to show result of the current transfer */ ixDmaAccCodeletShow(); /* Print out the average time for that configuration */ ixDmaAccCodeletReportAverageTime(transferLength); } return IX_SUCCESS;}/* * Function definition : ixDmaAccCodeletMain(void) * See header file for documentation. */IX_STATUS ixDmaAccCodeletMain(void){ UINT16 tLength[]={8,1024,16384,32768,65528}; IxDmaTransferMode tMode; IxDmaAddressingMode aMode; IxDmaTransferWidth tWidth; UINT16 localIndex; IX_STATUS retval; printf("Load DmaAcc Codelet\n"); ixDmaAccCodeletInit(IX_NPEDL_NPEID_NPEA); /*Code for Data Transfer*/ for (aMode = IX_DMA_INC_SRC_INC_DST; aMode <= IX_DMA_FIX_SRC_INC_DST; aMode++) { for(tMode = IX_DMA_COPY_CLEAR; tMode <= IX_DMA_COPY_REVERSE; tMode++) { for(tWidth = IX_DMA_32_SRC_32_DST; tWidth <= IX_DMA_BURST_SRC_BURST_DST; tWidth++) { for(localIndex = 0; localIndex < 5; localIndex++) { /* Do test perform for each configuration */ retval = ixDmaAccCodeletTestPerform(tLength[localIndex], tMode, aMode, tWidth); if (IX_SUCCESS != retval) { return IX_FAIL; } }/*End of lengthCode*/ /* Exclusion for invalid cases. In this address mode 8_SRFC_BURST_DST, 16_SRC_BURST_DST, 32_SRC_BURST_DST and BURST_SRC_BURST_DST are not valid */ if(IX_DMA_INC_SRC_FIX_DST == aMode) { if (IX_DMA_8_SRC_8_DST == tWidth) { tWidth =IX_DMA_32_SRC_BURST_DST; } else if (IX_DMA_BURST_SRC_32_DST == tWidth) { tWidth = IX_DMA_TRANSFER_WIDTH_INVALID; } } /* Exclusion for invalid cases. In this address mode BURST_SRC_8_DST, BURST_SRC_16_DST, BURST_SRC_32_DST and BURST_SRC_BURST_DST are not valid */ if(IX_DMA_FIX_SRC_INC_DST == aMode) { if ( IX_DMA_32_SRC_BURST_DST == tWidth) { tWidth = IX_DMA_TRANSFER_WIDTH_INVALID; } } }/*End of tWidth*/ } /*End of tMode*/ } /*End of aMode*/ return IX_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -