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; }
/* * ======== 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); }
/* * ======== 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); }