/************************************************************************************* * primFuncts_sct.c * * synopsis: Contains SCT-specific primitive functions which are common to both * DSPs, and the function which initializes the array of pointers to these * functions. * * in this file: initializePrimParams_sct, test * * related files: * listManager.c: Routines which manage the execution of a primitive list and * writing the reply data. * primFuncts.h: Declares the structure tag which communicates necessary information * to primitive functions. * primParams.h: Defines primitive ids which are used to index the array of pointers * to primitive functions, structure tags for primitive data and reply * data, and prototypes of primitive functions. * primParams_sct.h: Defines SCT-specific primitive ids. * * Douglas Ferguson, UW Madison (510) 486-5230 dpferguson@lbl.gov ************************************************************************************/ #include #include #include #include #include #include #include "resources.h" #include "comRegDfns.h" #include "primParams.h" extern char genStr[]; extern TIMER_Handle timer1; //General purpose timer, started in main(). extern far UINT8 heap[]; //General purpose heap. #if defined(I_AM_MASTER_DSP) extern far Module moduleConfigSet[N_MODULE_CONFIG_SETS][N_TOTMODULES]; #endif #pragma CODE_SECTION(test, "xcode"); /* file scope variables */ /************************************************************************************ * test * * synopsis: A general testing shell primitive intended for quick changes * (without having to change anything in primParams.h, get others to * re-build the DAQ program, etc.). Any amount of input and output data are * allowed. The test primitive is actually common to both SCT & Pixel, but is * placed in the detector specific file so that the tests will not potentially * conflict with each other. * ************************************************************************************/ #define LED_TEST 0 #define SCAN_TEST 1 #define CACHE_TEST 1 #define COMM_TEST 9 #define FLASH_WRITE 10 INT32 test(PrimData *primData) { INT32 returnCode= SUCCESS, status= SUCCESS; struct TEST_IN *testIn= (struct TEST_IN *) primData->priBodyPtr; UINT32 dataLen, testType, *dataPtr, replyLen, *repDataPtr, i, j; UINT32 *endPtr, wSize; struct LedTest { UINT32 read, led, state; } *ledTest; #if defined(I_AM_MASTER_DSP) #elif (defined(I_AM_SLAVE_DSP)&&(defined(REV_E))) struct CacheTest { UINT32 changeL2, l2Size, changeSdramCachability; UINT32 ce2[4], ce3[4]; UINT32 flush, range, rsize; } *cacheTest; UINT32 regVal; #endif primData->repBodyLength= replyLen= 0; dataLen= testIn->dataLen; dataPtr= (UINT32 *) &testIn->dataPtr; testType= *dataPtr; ++dataPtr; if (testType == LED_TEST) { ledTest= (struct LedTest *) dataPtr; sprintf(genStr, "Led Test params: len= %d, read:%d led:%d state:%d.\n", dataLen, ledTest->read, ledTest->led, ledTest->state); newInformation(__FILE__, __LINE__, genStr); } #if (defined(I_AM_MASTER_DSP)) else if (testType == FLASH_WRITE) { redLed_on; yellowLed_on; programFlash(0x80000, &heap[0]); redLed_off; yellowLed_off; } #endif #if defined(I_AM_MASTER_DSP) else if (testType == COMM_TEST) { status= sdspCommTest(dataPtr); if (status != SUCCESS) return status; } #elif (defined(I_AM_SLAVE_DSP)&&(defined(REV_E))) else if (testType == CACHE_TEST) { cacheTest= (struct CacheTest *) dataPtr; sprintf(genStr, "%s%d%s %s%d%s %s%d%s %s%d%s %s%d, %d, %d, %d%s %s%d, %d, %d, %d%s %s%d%s %s%d, %d%s", "Cache Test params: len= ", dataLen, "\n", "changel2?= ", cacheTest->changeL2, "\n", "L2 size= ", cacheTest->l2Size, "\n", "sdram change?= ", cacheTest->changeSdramCachability, "\n", "ce2[0:3]= ", cacheTest->ce2[0], cacheTest->ce2[1], cacheTest->ce2[2], cacheTest->ce2[3], "\n", "ce3[0:3]= ", cacheTest->ce3[0], cacheTest->ce3[1], cacheTest->ce3[2], cacheTest->ce3[3], "\n", "flush?= ", cacheTest->flush, "\n", "range, size= ", cacheTest->range, cacheTest->rsize, ".\n" ); newInformation(__FILE__, __LINE__, genStr); if (cacheTest->changeL2) { CACHE_setL2Mode((CACHE_L2Mode) cacheTest->l2Size); regVal= (*((UINT32 *) 0x01840000))<<0; WRITE_REG(RESERVED_REG_0, regVal); } else if (cacheTest->changeSdramCachability) { if (cacheTest->ce2[0]) {CACHE_enableCaching(CACHE_CE20); } if (cacheTest->ce2[1]) {CACHE_enableCaching(CACHE_CE21); } if (cacheTest->ce2[2]) {CACHE_enableCaching(CACHE_CE22); } if (cacheTest->ce2[3]) {CACHE_enableCaching(CACHE_CE23); } if (cacheTest->ce3[0]) {CACHE_enableCaching(CACHE_CE30); } if (cacheTest->ce3[1]) {CACHE_enableCaching(CACHE_CE31); } if (cacheTest->ce3[2]) {CACHE_enableCaching(CACHE_CE32); } if (cacheTest->ce3[3]) {CACHE_enableCaching(CACHE_CE33); } regVal= 0; regVal|= (*((UINT32 *) 0x01848280))<<0; regVal|= (*((UINT32 *) 0x01848284))<<4; regVal|= (*((UINT32 *) 0x01848288))<<8; regVal|= (*((UINT32 *) 0x0184828c))<<12; regVal|= (*((UINT32 *) 0x018482c0))<<16; regVal|= (*((UINT32 *) 0x018482c4))<<20; regVal|= (*((UINT32 *) 0x018482c8))<<24; regVal|= (*((UINT32 *) 0x018482cc))<<28; WRITE_REG(RESERVED_REG_5, regVal); } if (cacheTest->flush) { if (cacheTest->rsize == 0) { CACHE_flush(CACHE_L2ALL, (void*) 0x0, 0x0); } else { CACHE_clean(CACHE_L2, (void*) cacheTest->range, cacheTest->rsize); } } } #endif repDataPtr= NULL; /* must set to beginning of reply data buffer */ /*testOut->dataLen= 0; *//* change if reply data */ /* no changes needed below this point */ /*primData->repBodyLength= SIZEOF(struct TEST_OUT) +testOut->dataLen;*/ /*testOut->dataPtr= (UINT32 *) DEFAULT; */ /* Do not attempt to send data if it would exceed the list boundary. the extra 6 words are: 4 for the reply header, 2 for the pointer & length, which are sent along anyway. The pointer is "DEFAULT", indicating, in this case, that the data is in the reply buffer. The length could be computed using the primitive length, but it is sent along anyway to make life simpler for the host DAQ program. */ wSize= 6 +primData->repBodyLength; endPtr= primData->repBodyPtr +wSize; if (endPtr > primData->repBuffEnd) { newError(&returnCode, MSG_EXCEEDS_LIST_BOUND, ERROR_0, "test", "Reply data would exceed reply buffer boundary! ...sending pointer", __FILE__, __LINE__); /* testOut->replyLen stays the same, but the primitive reply length is reset to the minimum, and instead of DEFAULT a pointer to the data. */ /*primData->repBodyLength= SIZEOF(struct TEST_OUT); */ /*testOut->dataPtr= repDataPtr; */ return returnCode; } else { /* copy to reply buffer */ copyMem(repDataPtr, (primData->repBodyPtr +2),replyLen); } return returnCode; }