SPRAC21A June 2016 – June 2019 OMAP-L132 , OMAP-L138 , TDA2E , TDA2EG-17 , TDA2HF , TDA2HG , TDA2HV , TDA2LF , TDA2P-ABZ , TDA2P-ACD , TDA2SA , TDA2SG , TDA2SX , TDA3LA , TDA3LX , TDA3MA , TDA3MD , TDA3MV
Following are the three functions used for Cortex-M4 operations.
NOTE
The read, write, and copy functions use unrolled loops as it will generate more optimized code. With loop unrolled, it will check for loop condition after every 128 words (read or write) or 32 words (copy) transfer. Without loop unrolled, it will check for loop condition after each word transfer so it will generate less optimized code.
The C code for the write function is:
void memWrite(UWORD32 DstAddr, UWORD32 transSize) {
register UWORD32 wrData = 0xA5B5C5D5;
register UWORD32 i_wr;
register volatile UWORD32* wrAddr;
wrAddr = (UWORD32 *)DstAddr;
for(i_wr=0; i_wr<transSize; i_wr+=128){
/*128 words increment */
*wrAddr++ = wrData /*word 1*/
*wrAddr++ = wrData /*word 2*/
*wrAddr++ = wrData /*word 3*/
*wrAddr++ = wrData /*word 4*/
*wrAddr++ = wrData /*word 5*/
...
...
...
*wrAddr++ = wrData /*word 127*/
*wrAddr++ = wrData /*word 128*/
}
}
The C code for the read function is:
void memRead(UWORD32 SrcAddr, UWORD32 transSize) {
register UWORD32 rdData;
register UWORD32 i_rd;
register volatile UWORD32* rdAddr;
rdAddr = (UWORD32 *)SrcAddr;
for(i_rd=0; i_rd<transSize; i_rd+=128){
/*128 words increment */
rdData = *rdAddr++ /*word 1*/
rdData = *rdAddr++ /*word 2*/
rdData = *rdAddr++ /*word 3*/
rdData = *rdAddr++ /*word 4*/
rdData = *rdAddr++ /*word 5*/
...
...
...
rdData = *rdAddr++ /*word 127*/
rdData = *rdAddr++ /*word 128*/
}
}
The C code for the copy function is:
void memCopy(UWORD32 SrcAddr, UWORD32 DstAddr, UWORD32 transSize) {
register volatile UWORD32* rdAddr, *wrAddr;
register UWORD32 i;
rdAddr = (UWORD32 *)SrcAddr;
wrAddr = (UWORD32 *)DstAddr;
for(i=0; i<transSize; i=32){
/*32 words increment */
*wrAddr++ = *rdAddr++ /*word 1*/
*wrAddr++ = *rdAddr++ /*word 2*/
*wrAddr++ = *rdAddr++ /*word 3*/
*wrAddr++ = *rdAddr++ /*word 4*/
*wrAddr++ = *rdAddr++ /*word 5*/
...
...
...
*wrAddr++ = *rdAddr++ /*word 31*/
*wrAddr++ = *rdAddr++ /*word 32*/
}
}