/************************************************************************************ * errorCheck.c * * synopsis: This file contains routines which provide basic checks upon the * input parameters of (esp.) primitivies. * * in this file: moduleIndexCheck, checkSdspStatus * * Douglas Ferguson, UW Madison & LBNL dpferguson@lbl.gov ************************************************************************************/ #include #include #include #include #include "resources.h" #include "macros.h" #include "accessSlave.h" extern char genStr[]; extern far Module moduleConfigSet[N_MODULE_CONFIG_SETS][N_TOTMODULES]; char routineName[32]; #pragma CODE_SECTION(moduleIndexCheck, "xcode"); #pragma CODE_SECTION(checkSdspStatus, "xcode"); /************************************************************************************ * moduleIndexCheck: Checks an input module index & structure ID. ************************************************************************************/ INT32 moduleIndexCheck(UINT32 cfgSet, UINT32 module, UINT8 single, UINT8 checkPresent, UINT8 cfgBitfield) { INT32 returnCode= SUCCESS, err, i; Module *modulePtr; strcpy(routineName, "moduleIndexCheck"); err= FALSE; if (cfgBitfield) { for (i=0; i<32; ++i) if ((cfgSet & (1<= N_MODULE_CONFIG_SETS)) {err= TRUE; break; } } else if (cfgSet >= N_MODULE_CONFIG_SETS) {err= TRUE; } if (err) { sprintf(genStr,"%s%d%s%s%d%s","The input configuration set (", cfgSet, (cfgBitfield? ", bitfield) ":") "), "is out of range (max =",N_MODULE_CONFIG_SETS-1,").\n"); newErrFatalM(INVALID_CONFIG_SET, FATAL_ERR, routineName, genStr); } if ((module == NO_MODULE)) { newErrFatalM(INVALID_MODULE_NUM, FATAL_ERR, routineName, "No module specified!\n"); } else { if ((single) || ((!single) && (module != ALL_MODULES)) ) { if (module >= N_TOTMODULES) { sprintf(genStr,"%s%d%s","The input module index (", module,") is out of range!\n"); newErrFatalM(INVALID_MODULE_NUM, FATAL_ERR, routineName, genStr); } } } if ((checkPresent) && (module != ALL_MODULES)) { modulePtr= &moduleConfigSet[cfgSet][module]; if (!modulePtr->present) { sprintf(genStr,"%s%d%s","The input module index (", module, ") has no data loaded!\n"); newErrFatalM(BAD_MODULE_DATA, FATAL_ERR, routineName, genStr); } } return returnCode; } /************************************************************************************ * checkSdspStatus : Check the status of a SDSP, merging an error into the (input) * error code if a problem is found. Two tests are performed, * for the SDSP existing & for communications established. The tests are hooked * to bits 0 & 1 of the input test. ************************************************************************************/ INT32 checkSdspStatus(UINT8 sdsp, UINT8 testBits, char *routineName) { INT32 returnCode= SUCCESS, sdspStat; sdspStat= slaveIsOn(sdsp); if ( (testBits & 1) && (SDSP_DOES_NOT_EXIST(sdspStat)) ) { sprintf(genStr, "%s%d%s", "Attempt to communicate with a nonexistent SDSP (", sdsp, ").\n" ); newErrFatalM(SLAVE_DSP_DNE, FATAL_ERR, routineName, genStr); } else if ( (testBits & 2) && (SDSP_NOT_CONFIGURED(sdspStat)) ) { sprintf(genStr, "%s%d%s", "Attempt to communicate with a disabled SDSP (", sdsp, ").\n" ); newErrFatalM(SLAVE_DSP_OFF, FATAL_ERR, routineName, genStr); } return returnCode; }