/************************************************************************************ * validate.c * * synopsis: This file contains routines which check the input parameters (basic * ones only) for primitives and tasks. This serves a dual purpose: * 1) It keeps the code for the primitives/tasks themselves streamlined and * easier to read. * 2) It gives an indication on how much space is being used for such checks. * If this grows too large, these functions could be re-vamped & simplified, * or even exported to the host code. * * The code here also contains functions which transparently convert the input * parameters between older & newer formats for certain primitives & tasks; * this creates a greater degree of flexibility when introducing a new primitive * format, as the host code can be updated later. Update as needed. * ************************************************************************************/ #include #include #include #include #include #include "resources.h" #include "primFuncts.h" #include "listProc.h" extern char genStr[]; extern far unsigned char heap[]; extern TIMER_Handle timer1; /* general purpose timer, started in main() */ extern far UINT8 heap[]; //General purpose heap. extern struct PRIM_PARAMETERS primParameters[]; /* Since generally when updating a primitive its input structure will grow by a few words, to avoid any memory issues we simply use/re-use the heap. */ #pragma CODE_SECTION(pass_validate, "icode"); #pragma CODE_SECTION(startTask_validate, "xcode"); /************************************************************************************ * pass_validate * * synopsis: Passes the validation through to the assoc. primitive function. For * primitives which handle their error checking internally & do not need * conversion of their input stuctures. ************************************************************************************/ INT32 pass_validate(UINT32 revision, PrimData *primData) {return SUCCESS; } /************************************************************************************ * startTask_validate * * synopsis: Checks inputs to the startTask primitive & converts input structures * if necessary. ************************************************************************************/ INT32 startTask_validate(UINT32 revision, PrimData *primData) { INT32 status= SUCCESS; StartTaskIn *startTaskIn1= (StartTaskIn *) primData->priBodyPtr; StartTaskIn *startTaskIn; UINT32 taskType, taskRevision, *ptr[2]; TaskInput *oldTsi, *tsi; ScanControl *scan; taskType= startTaskIn1->taskType; taskRevision= startTaskIn1->taskRevision; oldTsi= &startTaskIn1->taskStruct; startTaskIn= (StartTaskIn *) &heap; *startTaskIn= *startTaskIn1; //1st copy to new structure. tsi= &startTaskIn->taskStruct; scan= (ScanControl *) tsi; #if (defined(I_AM_MASTER_DSP)) /* Note: The actual parameters of the primitive list are left untouched, and the primData pointer is modified to point to the heap. */ if (taskType == HISTOGRAM_CTRL_TASK) { //For default input, convert: if (taskRevision == R_HISTOGRAM_CTRL_TASK) { status= histoCtrl_convert(oldTsi, tsi); primData->priBodyPtr= (UINT32 *) startTaskIn; //re-point to heap. //X variable range list copying is handled in the converison routine. } /* For current task struct input, subtract 1 from task revision to allow insertTask to complete w/o error. No conversion is needed since the structure is actually current: */ else if (taskRevision == (R_HISTOGRAM_CTRL_TASK +1)) { --startTaskIn->taskRevision; primData->priBodyPtr= (UINT32 *) startTaskIn; //re-point to heap. /* Copy the two x range lists on top of the structure. If uniform points flags were used, it won't matter as the data is ignored then anyway: */ ptr[0]= (UINT32 *) oldTsi +SIZEOF(TaskInput); ptr[1]= (UINT32 *) tsi +SIZEOF(TaskInput); copyMem(ptr[0], ptr[1], 2*scan->general.nBins[0]); } //For any other revision #, pass-through & allow insertTask to catch error. else ; } #endif return status; }