/* * ======== cnxdiagExecute ======== */ RMS_STATUS cnxdiagExecute(NODE_EnvPtr env) { Int status = 0; CnxdiagObj *pCopyObj; Arg bufArg; Int nBufsize; Int * iPtr; Uns i; RMS_DSPMSG msg; Uns msgReady; Uns readyStreams; /* Dereference context structure stored in the env variable. */ pCopyObj = (CnxdiagObj*)env->moreEnv; nBufsize = pCopyObj->nBufsize; /* Fill buffer to send to GPP. */ iPtr = (Int *)pCopyObj->pBuf; for (i = 2; i < nBufsize; i++) { *iPtr++ = i; } /* Initialize msg structure. */ msg.cmd = ~(RMS_EXIT); /* Issue the pre-pared buffer to the output stream. */ STRM_issue(pCopyObj->outStream, pCopyObj->pBuf, nBufsize, nBufsize, NULL); for (;;) { /* Wait until input stream is ready, or until GPP message arrives. */ readyStreams = NODE_wait(env, &pCopyObj->outStream, 1, NODE_FOREVER, &msgReady); /* If a message has arrived. */ if (msgReady != 0) { /* Get message. */ NODE_getMsg(env, &msg, 0); if (msg.cmd == RMS_EXIT) { SYS_printf("Got RMS_EXIT\n"); break; } } /* If a buffer is ready on the output stream. */ if (readyStreams != 0) { /* Reclaim an empty buffer from the output stream. */ status = STRM_reclaim(pCopyObj->outStream, &pCopyObj->pBuf, NULL, &bufArg); if (status < 0) { SYS_printf("STRM_reclaim error: %d\n", status); } } } STRM_idle(pCopyObj->outStream, TRUE); return (RMS_EOK); }
/* * ======== DMMCOPY_TI_execute ======== */ RMS_STATUS DMMCOPY_TI_execute(NODE_EnvPtr env) { RMS_DSPMSG msg; LgUns size; Uns *fromGPP; Uns *toGPP; LgUns tempAddr1; LgUns tempAddr2; #ifdef _64P_ LgUns bufSize; #endif /* Initialize msg structure. */ msg.cmd = ~(RMS_EXIT); for (;;) { /* Get message. */ NODE_getMsg(env, &msg, NODE_FOREVER); if (msg.cmd == RMS_EXIT) { /* Exit if GPP says we should */ break; } else if (msg.cmd == DMM_SETUPBUFFERS) { /* Setup buffer addresses */ fromGPP = (Uns *)(msg.arg1); toGPP = (Uns *)(msg.arg2); } else if (msg.cmd == DMM_WRITEREADY) { /* How many MAUs to copy? */ #ifdef _64P_ size = (LgUns)(msg.arg1); bufSize = size; #else size = (LgUns)(msg.arg1) / sizeof(Uns); #endif tempAddr1 = (LgUns) toGPP; tempAddr2 = (LgUns) fromGPP; /* * Note: We can't use memcpy since pointers for buffers of * size > 64K will wrap around. Instead, we do our own * copying using a while loop with LgUns buffer pointers. */ #ifdef _64P_ BCACHE_invalidate((Ptr)fromGPP,bufSize); #endif while (size > 0 ) { #ifdef _64P_ *(volatile unsigned char *)tempAddr1 = *(volatile unsigned char *)tempAddr2; tempAddr1++; tempAddr2++; #else *(volatile Uns *)tempAddr1 = *(volatile Uns *)tempAddr2; tempAddr1 += (sizeof (Uns)); tempAddr2 += (sizeof (Uns)); #endif size--; } #ifdef _64P_ BCACHE_writebackInvalidate((Ptr)toGPP, bufSize); #endif /* Tell GPP that we're done copying */ NODE_putMsg(env, NODE_TOGPP, &msg, 0); } } return (RMS_EOK); }
unsigned int dsp_helloworld_execute(void *env) { dsp_msg_t msg; char *input; char *output; unsigned char done = 0; unsigned int i, j; char text[] = " World!"; while (!done) { NODE_getMsg(env, &msg, (unsigned) -1); switch (msg.cmd) { case 0: input = (char *) (msg.arg_1); output = (char *) (msg.arg_2); break; case 1: { unsigned int size; size = (unsigned int) (msg.arg_1); BCACHE_inv((void*) input, size, 1); for(i = 0; input[i]; i++) output[i] = input[i]; for(j = 0; text[j]; j++) output[i + j] = text[j]; output[i + j] = 0; BCACHE_wbInv((void*) output, size, 1); msg.cmd = 2; NODE_putMsg(env, NULL, &msg, 0); break; } case 4: { int* data = (int*)msg.arg_1; int length = (int)msg.arg_2; int i; BCACHE_inv((void*) data, length*sizeof(int), 1); for(i = 0; i < length; i++) { data[i] += 10; } BCACHE_wbInv((void*) data, length*sizeof(int), 1); msg.cmd = 42; NODE_putMsg(env, NULL, &msg, 0); break; } case 0x80000000: done = 1; break; } } return 0x8000; }
/* * ======== STRMCOPY_TI_execute ======== */ RMS_STATUS STRMCOPY_TI_execute(NODE_EnvPtr env) { StrmcopyObj *copyObj; Uns bytesRead; Arg bufArg; Uns *inBuf; Uns *outBuf; RMS_DSPMSG msg; Uns msgReady; Uns readyStreams; Bool firstFrame = TRUE; #if DLLDEBUG UTL_breakPoint(); #endif /* Dereference context structure stored in the env variable. */ copyObj = (StrmcopyObj*)env->moreEnv; inBuf = copyObj->inBuf; outBuf = copyObj->outBuf; /* Initialize msg structure. */ msg.cmd = ~(RMS_EXIT); /* Prime the input stream with an empty buffer. */ STRM_issue(copyObj->inStream, inBuf, copyObj->inSize, copyObj->inSize, 0); /* Until end of stream indicated, receive and send a host buffer: */ for (;;) { /* * The following calls to INST2_COLLECT are only for testing porpose, * this calls will simulate the behavior of the INST2 meassurements of * the USN layer */ #ifdef _INST2_ /* collect time before the blocking call */ INST2_COLLECT(INST2_FORMAT_BENCH | INST2_TAG_WAIT | INST2_SUFFIX_START, 0, 0, 0) #endif /* Wait until input stream is ready, or until GPP message arrives. */ readyStreams = NODE_wait(env, ©Obj->inStream, 1, NODE_FOREVER, &msgReady); #ifdef _INST2_ /* collect time after the blocking call */ INST2_COLLECT(INST2_FORMAT_BENCH | INST2_TAG_WAIT | INST2_SUFFIX_STOP, 0, 0, 0) #endif /* If a message has arrived. */ if (msgReady != 0) { /* Get message. */ NODE_getMsg(env, &msg, 0); if (msg.cmd == RMS_EXIT) { break; } } /* If a buffer is ready on the input stream. */ if (readyStreams != 0) { /* If first iteration, reclaim on output buffer not needed. */ if (firstFrame == TRUE) { firstFrame = FALSE; } else { /* Reclaim output buffer. */ STRM_reclaim(copyObj->outStream, (Ptr *)&outBuf, NULL, &bufArg); } /* Get the buffer from the input stream. */ bytesRead = STRM_reclaim(copyObj->inStream, (Ptr *)&inBuf, NULL, &bufArg); /* Copy the buffer into the output buffer. */ memcpy(outBuf, inBuf, bytesRead); /* Send an output buffer to the output stream. */ STRM_issue(copyObj->outStream, outBuf, bytesRead, copyObj->outSize, 0); /* Send an empty buffer to the input stream. */ STRM_issue(copyObj->inStream, inBuf, copyObj->inSize, copyObj->inSize, 0); } } /* Idle open streams before the delete phase. */ STRM_idle(copyObj->inStream, TRUE); STRM_idle(copyObj->outStream, TRUE); /* Reclaim any outstanding buffers in the data streams. */ STRM_reclaim(copyObj->inStream, (Ptr *)&inBuf, NULL, &bufArg); if (!firstFrame) { STRM_reclaim(copyObj->outStream, (Ptr *)&outBuf, NULL, &bufArg); } SYS_printf("ExEcUtEd!\n"); #if DLLDEBUG UTL_breakPoint(); #endif return (RMS_EOK); }
/* * ======== DMMCOPY_TI_execute ======== */ RMS_STATUS VISION_TI_execute(NODE_EnvPtr env) { RMS_DSPMSG msg; unsigned int size, tempSize, sizeProut; unsigned char* tempAddrIn; unsigned char* tempAddrOut; unsigned int x,y; unsigned int downsizefactor; //unsigned char quality_factor = 50; // From 0 to 99 (99=high) //unsigned char dri_jpeg_header = 0; //unsigned char* end; struct img_struct imgIn; struct img_struct imgOut; struct img_struct imgTemp; /* Initialize msg structure. */ msg.cmd = ~(RMS_EXIT); for (;;) { /* Get message. */ NODE_getMsg(env, &msg, NODE_FOREVER); if (msg.cmd == VISION_WRITEREADY) { /* How many MAUs to copy? */ size = (unsigned int)(msg.arg1); /* * Note: We can't use memcpy since pointers for buffers of * size > 64K will wrap around. */ BCACHE_invalidate((Ptr)(imgIn.buf),size); //Copy Input to Output through tempBuffer: 2 ways to read image pixels tempAddrOut = imgTemp.buf; tempAddrIn = imgIn.buf; tempSize = (2*imgIn.w*imgIn.h)-1; //? while (tempSize > 0 ) { *tempAddrOut = *tempAddrIn; tempAddrOut++; tempAddrIn++; tempSize--; } tempAddrOut = imgOut.buf; tempAddrIn = imgTemp.buf; for(y=0;y<imgOut.h;y++) { for(x=0;x<imgOut.w;x++) { //2 bytes per pixel: UY(px 1,3,5,...) or VY(px 2,4,6,...) *tempAddrOut = *tempAddrIn; tempAddrOut++; tempAddrIn++; *tempAddrOut = *tempAddrIn; tempAddrOut++; tempAddrIn++; } } BCACHE_writebackInvalidate((Ptr)(imgOut.buf), size); /* Tell GPP that we're done copying */ NODE_putMsg(env, NODE_TOGPP, &msg, 0); } else if (msg.cmd == RMS_EXIT) { /* Exit if GPP says we should */ break; } else if (msg.cmd == VISION_SETUPBUFFERS) { /* Setup buffer addresses */ imgIn.buf = (unsigned char *)(msg.arg1); imgOut.buf = (unsigned char *)(msg.arg2); }else if(msg.cmd == VISION_SETUPTEMPBUFFERS){ imgTemp.buf = (unsigned char *)(msg.arg1); }else if(msg.cmd == VISION_SETUPIMAGESIZE){ imgIn.w = *((unsigned int *)(imgIn.buf)); imgIn.h = *((unsigned int *)(imgIn.buf+4)); imgOut.w = *((unsigned int *)(imgIn.buf+8)); imgOut.h = *((unsigned int *)(imgIn.buf+12)); } } return (RMS_EOK); }