00001 /************************************************************************************ 00002 * primParams.h 00003 * 00004 * synopsis: Defines primitive ids which are used to index the array of pointers to 00005 * primitive functions, structure tags for primitive data and reply data, 00006 * and prototypes of primitive functions. 00007 * 00008 * related files: 00009 * listManager.c: Routines which manage the execution of a primitive list and 00010 * writing the reply data. 00011 * primFuncts.c: Contains primitive execution functions common to the master and the 00012 * slaves and the function which initializes the primParameters array 00013 * of structures. 00014 * masterPrimFuncts.c/slavePrimFuncts.c: Contain primitive execution functions 00015 * specific to the master/slave DSP. 00016 * primFuncts.h: Declares the structure tag which communicates necessary information 00017 * to primitive functions. 00018 * 00019 * Damon Fasching, UW Madison fasching@wisconsin.cern.ch 00020 * Douglas Ferguson, UW Madison (510) 486-5230 dpferguson@lbl.gov 00021 * 00022 * modifications/bugs 00023 * - Split the primitive IDs into 3 sets, so that future primitives can 00024 * be placed in the appropriate section (common/slave/master) without 00025 * affecting the already existing primitive lists on the host machines. 00026 * Currently primitives must be added to the end of the entire list to 00027 * avoid ID changes of existing primitives & thus re-writes of the 00028 * primitive lists. Updated the example. 10.04.02 dpsf 00029 * - Moved rodConfiguration #defines to rodConfiguration.h, where 00030 * they belong. 11.04.02 dpsf 00031 * 00032 ************************************************************************************/ 00033 #ifndef PRIM_PARAMS 00034 #define PRIM_PARAMS 00035 00036 #include "processor.h" 00037 #include "utilities.h" 00038 #include "serialStreams.h" 00039 #include "scanControl.h" 00040 #include "bocStructure.h" 00041 #include "rodConfiguration.h" 00042 #include "router.h" 00043 00044 #if (defined(I_AM_MASTER_DSP) || defined(I_AM_SLAVE_DSP)) 00045 #include "primFuncts.h" 00046 #endif 00047 00048 /************************************************************************************* 00049 * GENERAL 00050 ************************************************************************************* 00051 * 00052 * Primitive lists sent from one CPU to another and reply lists returned from the 00053 * recipient CPU have a 3 parts: 00054 * list header: tagged by the structure MSG_LIST_HEAD declared in msgBuff.h 00055 * list body: composed of the list of primitive or reply messages 00056 * list trailer: tagged by the structure MSG_LIST_TAIL declared in msgBuff.h 00057 * 00058 * The primitive and reply messages in the list body have 2 parts: 00059 * message header: tagged by the structure MSG_HEAD declared in msgBuff.h 00060 * message body: (optional) primitive specific data. If there is primitive 00061 * specific data, there should be a structure tag for it defined 00062 * in primParams.h (this file). There should be separate tags for 00063 * input and/or output data as needed. 00064 * 00065 * The primitive functions themselves never see the listHeader, listBody or msgHeader. 00066 * These structures are interpreted by the interface routines, readListWrapper() and 00067 * execPrim() in listManager.c. Because of this, changes in the common structures do 00068 * not require changes to any of the primitive functions, only to one or the other of 00069 * the interface routines. This reduces effort but more importantly reduces the 00070 * possibility of errors. 00071 * 00072 * On receipt of a new primitive list, readListWrapper() extracts the information from 00073 * the list header and the list trailer and checks it for errors. This information 00074 * guides the execution of the list. 00075 * 00076 * execPrim() is called once for each primitive in a primitive list. execPrim() 00077 * extracts the information from the message header, checks it for errors and branches 00078 * to the appropriate primitive function. Primitive functions are all of type INT32 00079 * and have a single argument, a pointer to a structure of type PRIM_DATA declared in 00080 * primFuncts.h. execPrim() fills the PRIM_DATA structure before branching to the 00081 * primitive function. 00082 * 00083 * All primitive functions receive a pointer to struct PRIM_DATA as an argument. 00084 * There will be many authors of primitives, so it is important that the use of this 00085 * structure is clear. The structure is described in detail here, followed by 00086 * instructions of how to add a primitive, with an example. 00087 * 00088 ************************************************************************************* 00089 * The PRIM_DATA data structure 00090 ************************************************************************************* 00091 * 00092 * PRIM_DATA is a 5 element structure which is passed to each primitive function. It 00093 * is the sole argument passed to the primitive functions and is filled for all 00094 * primitives by the function execPrim() in listManager.c. It's use by a primitive 00095 * function may be tricky so requires care! In particular, 2 of the elements in 00096 * PRIM_DATA are themselves pointers to structures defined by the author of each 00097 * primitive. These are priBodyPtr and repBodyPtr which point to data used by the 00098 * primitive and returned from the primitive, respectively. The structures tags which 00099 * describe this data are defined by the primitive authors in this file (primParams.h). 00100 * The elements of PRIM_DATA are now described: 00101 * 00102 * UINT32 *priBodyPtr - This is a pointer to the (optional) message body. As 00103 * described above, the message body contains primitive specific data which should be 00104 * described by a structure whose tag is in this file (primParams.h). The executable 00105 * on the CPU which sent the primitive list is also built with primParams.h and so 00106 * uses the same structures to build the primitives. This ensures that the data 00107 * described by the structure in primParams.h is what the primitive function receives. 00108 * 00109 * UINT32 priBodyLength - This is the number of 4 byte words in the primitive body. 00110 * This may not always be the same for a given primitive if, for example, one of the 00111 * primitive data structure elements is of variable length, as in the example below. 00112 * 00113 * UINT32 *repBodyPtr - This is a pointer to the (optional) message body of the reply 00114 * data. If there is reply data from the primitive, this pointer tells the primitive 00115 * function where it should put that data. Again, the author of the primitive is 00116 * responsible to define a structure tag to describe this data. That tag should also 00117 * be in this file (primParams.h). 00118 * 00119 * UINT32 repBodyLength - This is the number of 4 byte words in the reply message body. 00120 * It should NOT include the reply message header, tagged by MSG_HEAD, which is added 00121 * by execPrim() and which the primitive function knows nothing about. execPrim() 00122 * initializes repBodyLength to 0; the primitive function does not need to set it to 0 00123 * if there is no reply data. 00124 * 00125 * UINT32 *repBuffEnd - This points to the last valid address where a primitive can 00126 * write reply data. The primitive function can use this to check that the bounds of 00127 * the reply buffer are not exceeded. The error code MSG_EXCEEDS_LIST_BOUND can be 00128 * returned if the reply message has been truncated. The interface routine, execPrim(), 00129 * also checks that a primitive has not not exceeded the boundaries of the reply buffer. 00130 * 00131 * The interface routines do not look at the input data, they just pass a pointer to 00132 * the data. So just as the primitive routines are not affected by changes in the 00133 * common structures, the interface routines are not affected by changes to primitive 00134 * functions and the associated data structures. This division means that only people 00135 * familiar with a particular piece of code ever have to edit it, and it limits the 00136 * amount of code which is affected by changes. This all reduces the likelihood of 00137 * introducing bugs when making such changes. 00138 * 00139 ************************************************************************************* 00140 * readListWrapper(), execPrim() and CPU to CPU consistency checks 00141 ************************************************************************************* 00142 * 00143 * Each primitive has up to five items defined in this header file: 00144 * 00145 * ID (required) 00146 * revision number (required) 00147 * structure tag for input data (required if there is input data) 00148 * structure tag for output data (required if there is reply data) 00149 * legal values of parameters (recommended if there are illegal values) 00150 * 00151 * Primitive functions are called from the interface function, execPrim(), based on 00152 * the primitive ID, which is an element of the MSG_HEAD structure. The executables 00153 * on both the sending and receiving CPUs are built with this header file. The CPU 00154 * which builds and sends the primitive loads ID into MSG_HEAD to communicate which 00155 * primitives are to be executed. The CPU which receives the primitive list extracts 00156 * ID from MSG_HEAD and branches to a primitive functions based on ID. 00157 * 00158 * The branching is done by execPrim(). Within execPrim() the primitive ID is used 00159 * as an index of an array of structures which has one array element per primitive. 00160 * The structure tag, PRIM_PARAMETERS, is defined in primFuncts.h. It has 2 elements: 00161 * 00162 * struct PRIM_PARAMETERS { 00163 * INT32 (*primFunction)(struct PRIM_DATA *); 00164 * INT32 primRevision; 00165 * }; 00166 * 00167 * primFunction is a pointer to the primitive function. primRevision is the current 00168 * revision of the primitive. This is needed to ensure the executables of the sending 00169 * and receiving CPUs were built with the same version. 00170 * 00171 * Because primitive IDs index an array of pointers to primitive functions, they 00172 * must be sequential. Defining the IDs according to the model below, e.g. 00173 * 00174 * #define ECHO 0 00175 * #define MEMORY_TEST (1 + (ECHO)) 00176 * #define SET_ERRMSG_MASK (1 + (MEMORY_TEST)) 00177 * 00178 * etc. ensures that the primitive IDs are sequential. 00179 * 00180 * Note: The primitive IDs have been divided into 3 sets: common to both master & slave 00181 * DSPs, slave only, master only. New primitives belonging to a given set should be 00182 * placed at the end of the set, so that the previously written primitive lists 00183 * stored on the host computers still remain valid. They are still ordered sequentially 00184 * within the sets to simplify the listManager code. (Table lookups in execPrim, 00185 * checkPrimHeader and initializePrimParams translate the IDs into indices). 00186 * 00187 * The revision number is intended to ensure that both CPUs, sender and receiver, 00188 * are using the same version of a primitive. In particular, there could be problems 00189 * if the definition of the input data structure or the output data structure is not 00190 * the same on both CPUs. The primitive revision is an element, primRevision, of the 00191 * MSG_HEAD structure which is filled by the sending CPU. The receiving CPU checks 00192 * the transmitted version of primRevision in the message header with its local copy 00193 * in the PRIM_PARAMETERS structure and aborts with an error message if there is a 00194 * mismatch. This check is performed in a single place, in the interface routine 00195 * execPrim() in listManager.c. It should NOT be performed by the primitive 00196 * functions. In fact, execPrim() does not pass the revision number to the primitive. 00197 * 00198 * There are no restrictions on the mnemonic constants which are used to define the 00199 * ID, the revision and the structure tags for the input and output data of the 00200 * primitive functions. However, because these constants will be used not only by the 00201 * author of the primitive but also by the authors of code which builds primitive 00202 * lists, there should be some consistency in how they are defined. The following 00203 * model has been used so far: 00204 * The ID should indicate what the primitive does. 00205 * The revision should be the ID preceded by R_ and should be of the form xxyy 00206 * where xx is the major revision number and yy is the minor revision number. 00207 * The input structure tag should be the ID appended with _IN 00208 * The output structure tag should be the ID appended with _OUT. 00209 * For example say we have primitive which sorts the input data and returns this as 00210 * output data and that this primitive follows a primitive with ID ECHO in the list. 00211 * We would have: 00212 * #define SORT_DATA (1 + (ECHO)) ID is mnemonic and sequential 00213 * #define R_SORT_DATA 300 revision number 3.00 00214 * struct SORT_DATA_IN { structure tag for input data 00215 * char *unsorted; 00216 * }; 00217 * struct SORT_DATA_OUT { structure tag for output data 00218 * char *sorted; 00219 * }; 00220 * 00221 * In some cases, it may also be useful to define mnemonics for legal values of 00222 * parameters which are passed in the structures. See, e.g., SET_LED below. 00223 * 00224 * Finally, the constant PRIM_LIST_REVISION, below, is intended to ensure that the 00225 * primitives which are defined on both CPUs are the same and in the same order, i.e. 00226 * a given ID number corresponds to the same primitive on both sides. 00227 * PRIM_LIST_REVISION should be incremented in the following situations: 00228 * 00229 * 1) A primitive is added to this file. 00230 * 2) A primitive is removed from this file. 00231 * 3) The primitives in this file are reordered. 00232 * *) It does NOT need to be incremented in the event that individual primitives are 00233 * revised. PRIM_REVISION takes care of that. 00234 * 00235 * The primitive list and the reply list have a common header structure which is tagged 00236 * by MSG_LIST_HEAD in msgBuff.h. This structure has an element, primListRevision, 00237 * which the sending CPU fills with its copy of PRIM_LIST_REVISION. The receiving CPU 00238 * checks this against its copy of PRIM_LIST_REVISION and aborts if there is a 00239 * mismatch. This check is performed in a single place, in the interface routine 00240 * readListWrapper() in listManager.c. 00241 * 00242 ************************************************************************************* 00243 * primitive function skeletons with and without return data 00244 ************************************************************************************* 00245 * 00246 * -- SIZEOF(x) is defined as sizeof(x) >> 2, i.e. it is the size in 32 bit words. 00247 * -- In some cases there might not be a structure for the return data, e.g. if it 00248 * -- it's format or size is not completely specified. In those cases, the last 00249 * -- line would be primData->repBodyLength = N; where N is the size in 32 bit words. 00250 * see, e.g., rwFifo in masterPrimFuncts.c. 00251 * 00252 * INT32 noReturnDataSkel(struct PRIM_DATA *primData) { 00253 * 00254 * INT32 returnCode = SUCCESS; 00255 * 00256 * struct NO_RETURN_DATA_SKEL_IN *noReturnDataSkelIn = 00257 * (struct NO_RETURN_DATA_SKEL_IN *)primData->priBodyPtr; 00258 * 00259 * -- code goes here -- 00260 * 00261 * return returnCode; 00262 * } 00263 * 00264 *** 00265 * 00266 * INT32 returnDataSkel(struct PRIM_DATA *primData) { 00267 * 00268 * INT32 returnCode = SUCCESS; 00269 * 00270 * struct RETURN_DATA_SKEL_IN *returnDataSkelIn = 00271 * (struct RETURN_DATA_SKEL_IN *)primData->priBodyPtr; 00272 * struct RETURN_DATA_SKEL_OUT *returnDataSkelOut = 00273 * (struct RETURN_DATA_SKEL_OUT *)primData->repBodyPtr; 00274 * 00275 * -- code goes here -- 00276 * 00277 * primData->repBodyLength = SIZEOF(struct RETURN_DATA_SKEL_OUT); 00278 * 00279 * return returnCode; 00280 * } 00281 * 00282 * Note that the last line of code which assigns repBodyLength may take other forms. 00283 * For example the echo primitive (in primFuncts.c) has in the body an arbitrary 00284 * number of data words given by priBodyLength and pointed to by priBodyPtr both 00285 * members of the PRIM_DATA structure. The return message will have the same number 00286 * of words in its body and they will be placed at repBodyPtr, also a member of the 00287 * PRIM_DATA structure. So there we do not have a structure indicating where the 00288 * primitive and reply data are or their sizes. repBodyLength is assigned by the line 00289 * primData->repBodyLength = primData->priBodyLength. 00290 * Other examples of this type of exception are in the rwFifo() in masterPrimFuncts.c 00291 * and in the sortData example below. 00292 * 00293 * Note also that in noReturnDataSkel, it was not necessary to set repBodyLength to 00294 * 0. This is done in the interface routine, execPrim(), from which all primitives 00295 * are called. 00296 * 00297 * 00298 * 00299 ************************************************************************************* 00300 * EXAMPLES 00301 * How to add a primitive in 5 easy steps. 00302 ************************************************************************************* 00303 * 00304 * Here, the procedure to add a primitive function, checkBit(), is described. 00305 * checkBit() checks whether a bit in a register is set. The result is returned in a 00306 * reply message. checkBit is a primitive common to both types of DSPs, so it is 00307 * placed at the end of the common section. 00308 * 00309 * 1) In primParams.h, define the constant mnemonic for the primitive ID, the 00310 * revision number and structure tags for the input and output (reply) data. 00311 * 00312 * #define CHECK_BIT (1 + (<previously last primitive>)) 00313 * #define R_CHECK_BIT 100 00314 * struct CHECK_BIT_IN { 00315 * UINT32 registerId; 00316 * UINT32 bitNumber; 00317 * }; 00318 * struct CHECK_BIT_OUT { 00319 * UINT32 bitSet; 00320 * }; 00321 * 00322 * #define LAST_COMMON_PRIMITIVE (CHECK_BIT) 00323 * 00324 * 2) In primParams.h, near the bottom, add the prototype for the primitive function. 00325 * 00326 * INT32 checkBit(struct PRIM_DATA *); 00327 * 00328 * 3) In primParams.h increment PRIM_LIST_REVISION. 00329 * 00330 * 4) Update primIDList & the primParameters array inside initializePrimParams in 00331 * primFuncts.c; add in the new primitive in the appropriate spot (bottom 00332 * of common, slave-only, or master-only functions): 00333 * 00334 * primIDList[++primLoop]= CHECK_BIT; 00335 * primParameters[primLoop].primFunction= checkBit; 00336 * primParameters[primLoop].primRevision= R_CHECK_BIT; 00337 * 00338 * 5) In primFuncts.c, slavePrimFuncts.c or masterPrimFuncts.c, write the routine... 00339 * 00340 * INT32 checkBit(struct PRIM_DATA *primData) { 00341 * 00342 * INT32 returnCode = SUCCESS; 00343 * INT32 error; 00344 * UINT32 registerId; 00345 * UINT32 bitNumber; 00346 * UINT32 bitSet; 00347 * 00348 * struct CHECK_BIT_IN *checkBitIn = 00349 * (struct CHECK_BIT_IN *)primData->priBodyPtr; 00350 * struct CHECK_BIT_OUT *checkBitOut = 00351 * (struct CHECK_BIT_OUT *)primData->repBodyPtr; 00352 * 00353 * registerId = checkBitIn->registerId; 00354 * bitNumber = checkBitIn->bitNumber; 00355 * 00356 * error = readRegister( registerId, 1, bitNumber, &bitSet); 00357 * 00358 * if (error < 0) { 00359 * addError(&returnCode,error, "checkBit","readRegister", __FILE__, __LINE__); 00360 * if (FATAL(returnCode)) { return returnCode; } 00361 * } 00362 * 00363 * checkBitOut->bitSet = bitSet; 00364 * primData->repBodyLength = SIZEOF(struct CHECK_BIT_OUT); 00365 * 00366 * return returnCode; 00367 * } 00368 * 00369 * (Note how an error return from a function call is handled.) 00370 * 00371 * Now we add a primitive function, sortData(), just after checkBit(). sortData sorts 00372 * input byte data and returns the sorted list. Like checkBit, sortData has both input 00373 * and output data. However, neither the input nor the output data has an associated 00374 * structure. They are after all just unstructured data lists of unspecified length. 00375 * 00376 * 1) In primParams.h, define the constant mnemonic for the primitive ID and the 00377 * revision number. In this case there are no structure tags. 00378 * 00379 * #define SORT_DATA (1 + (CHECK_BIT)) 00380 * #define R_SORT_DATA 100 00381 * 00382 * #define LAST_COMMON_PRIMITIVE (SORT_DATA) 00383 * 00384 * 2) In primParams.h, near the bottom, add the prototype for the primitive function. 00385 * 00386 * INT32 sortData(struct PRIM_DATA *); 00387 * 00388 * 3) In primParams.h increment PRIM_LIST_REVISION. 00389 * 00390 * 4) Update primIDList & the primParameters array inside initializePrimParams: 00391 * 00392 * primIDList[++primLoop]= SORT_DATA; 00393 * primParameters[primLoop].primFunction= sortData; 00394 * primParameters[primLoop].primRevision= R_SORT_DATA; 00395 * 00396 * 5) In primFuncts.c, slavePrimFuncts.c or masterPrimFuncts.c, write the routine... 00397 * 00398 * INT32 sortData(struct PRIM_DATA *primData) { 00399 * 00400 * INT32 returnCode = SUCCESS; 00401 * char *inPtr, *outPtr; 00402 * char tmp; 00403 * UINT32 numElements, outer, inner; 00404 * 00405 * inPtr = primData->priBodyPtr; 00406 * outPtr = primData->repBodyPtr; 00407 * numElements = 4 * primData->priBodyLength; 00408 * 00409 * if ((UINT32)inPtr + numElements > (UINT32)primData->repBuffEnd) { 00410 * newError(&returnCode, MSG_EXCEEDS_LIST_BOUND, FATAL_ERR, "sortData", 00411 * "reply data will exceed reply buffer boundary...aborting", 00412 * __FILE__, __LINE__); 00413 * return returnCode; 00414 * } 00415 * 00416 * for (outer = 0; outer < (numElements - 2); ++outer) { 00417 * for (inner = 0; inner < (numElements - 2 - outer); ++inner) { 00418 * if ( *(inPtr + (char *)inner) > *(inPtr + (char *)(inner+1))) { 00419 * tmp = *(inPtr + (char *)inner); 00420 * *(inPtr + (char *)inner) = *(inPtr + (char *)(inner+1)); 00421 * *(inPtr + (char *)(inner+1)) = tmp; 00422 * } 00423 * } 00424 * *(outPtr + (char *)(numElements-1-outer)) = 00425 * *(inPtr + (char *)(numElements-1-outer)); 00426 * } 00427 * *outPtr = *inPtr; 00428 * 00429 * primData->repBodyLength = primData->priBodyLength; 00430 * 00431 * return returnCode; 00432 * } 00433 * 00434 * Note that here a check has been added to make sure the reply data does not exceed 00435 * the reply data buffer. 00436 * 00437 * D Fasching 00438 */ 00439 #define PRIM_LIST_REVISION 111 00440 00441 00442 00443 00444 00445 /************************************************************************************ 00446 * Primitives common to all DSPs go here 00447 * Note: some of these primitives (eventTrapSetup, triggerMask, setTrigger) are used 00448 * to coordinate the DSPs with each other or other electronics on the ROD (such as 00449 * the router). These primitives should be sent to the master DSP from the host; the 00450 * master DSP primitive will then set the appropriate board registers, etc. and pass 00451 * on the primitive to the slave DSP. The primitive passing software will not break 00452 * if the host sends one of these primitives directly to a slave, but slave 00453 * applications might break as a result of inconsistent parameter settings. 00454 ************************************************************************************/ 00455 #define COMMON_PRIMITIVES_BASE 0x0 00456 00457 /* Echo the primitive message body back in the reply message body. */ 00458 #define ECHO (COMMON_PRIMITIVES_BASE) 00459 #define R_ECHO 100 00460 /* echo's input & output data is unstructured. */ 00461 00462 /* 00463 * Set error severity mask - levels which are masked will not write an error message 00464 * to the text buffer. 00465 * IN: errMsgMask: value to set errMsgMask to; 00466 * DEFAULT means do not change the value 00467 * OUT: errMsgMaskOut->errMsgMask: value of errMsgMask at end of this routine 00468 */ 00469 #define SET_ERRMSG_MASK (1 + (ECHO)) 00470 #define R_SET_ERRMSG_MASK 100 00471 struct SET_ERRMSG_MASK_IN { 00472 UINT32 errMsgMask; 00473 }; 00474 struct SET_ERRMSG_MASK_OUT { 00475 UINT32 errMsgMask; 00476 }; 00477 00478 /* 00479 * Pause the execution of the primitive list. List execution will resume when the 00480 * RESUME bit is set in the command register. 00481 */ 00482 #define PAUSE_LIST (1 + (SET_ERRMSG_MASK)) 00483 #define R_PAUSE_LIST 100 00484 00485 /* eventTrapSetup: 00486 * Sets the event trapping parameters for a particular slave. They need to be set 00487 * in the slave DSP and in the router fpga. Common to Master/Slave, however 00488 * eventTrapSetup is intended to be a HOST to MASTER DSP primitive only; the master 00489 * DSP then sets up the router registers and passes a primitive list to call 00490 * eventTrapSetup on the slave DSP. Trap configuation is not independent, if only 00491 * one trap is used, it must be trap 0. The primary purpose for trap 1 is to have 00492 * a way of running short immediate tasks with a different function (like trapping 00493 * events) on the DSP, while it continues a task such as occupancy counting. 00494 */ 00495 #define EVENT_TRAP_SETUP (1 + (PAUSE_LIST)) 00496 #define R_EVENT_TRAP_SETUP 103 00497 struct EVENT_TRAP_SETUP_IN { 00498 UINT32 slvBits, numberOfEvents, timeoutInUsec; 00499 UINT32 extRouterSetup, distribute; 00500 UINT32 releaseFrames, permitBackPressure, dataMode, sLink, 00501 format, trapStray, iterLimit; 00502 UINT32 trapConfig[2], trapExclusionFlag[2], trapFunction[2], 00503 trapMatch[2], trapModulus[2], trapRemainder[2]; 00504 }; 00505 struct EVENT_TRAP_SETUP_OUT { 00506 UINT32 errorCode; 00507 }; 00508 #define COLLECT_FOREVER 0 00509 #define KEEP_EVENTS 0 00510 00511 #define TRAP_DISTRIB_PRIMARY 0 00512 #define TRAP_DISTRIB_SECONDARY 1 00513 #define TRAP_DISTRIB_BOTH 2 00514 #define TRAP_DISTRIB_NEITHER 3 00515 00516 #define TRAP_FMT_NORMAL 0 00517 #define TRAP_FMT_ERROR 1 00518 00519 /* Quickly set a section of the DSP's memory */ 00520 #define SET_MEMORY (1 + (EVENT_TRAP_SETUP)) 00521 #define R_SET_MEMORY 100 00522 struct SET_MEMORY_IN { 00523 UINT32 *start, size, val; 00524 }; 00525 00526 /* Quickly copy one section of the DSP's memory into another section */ 00527 #define COPY_MEMORY (1 + (SET_MEMORY)) 00528 #define R_COPY_MEMORY 100 00529 struct COPY_MEMORY_IN { 00530 UINT32 *source, *destination, size; 00531 }; 00532 00533 /* New memory test, designed to work with full code (ie not the memory-test mode) */ 00534 #define MEMORY_TEST (1 + (COPY_MEMORY)) 00535 #define R_MEMORY_TEST 102 00536 struct MEMORY_TEST_IN { 00537 UINT32 *start, size, repetitions[6], errorsBeforeFail, continueOnError; 00538 UINT32 nReads, dmaFlag; 00539 }; 00540 struct MEMORY_TEST_OUT { 00541 UINT32 returnCode; 00542 }; 00543 00544 /* Turn an LED on or off. */ 00545 #define SET_LED (1 + (MEMORY_TEST)) 00546 #define R_SET_LED 104 00547 struct SET_LED_IN { 00548 UINT32 ledNum, ledState; 00549 }; 00550 #define YELLOW_LED 0 00551 #define GREEN_LED 1 00552 #define RED_LED 2 00553 00554 #define OFF 0 00555 #define ON 1 00556 #define TOGGLE 2 00557 00558 /* Flash an LED. Period and number of flashes are settable parameters. */ 00559 #define FLASH_LED (1 + (SET_LED)) 00560 #define R_FLASH_LED 103 00561 struct FLASH_LED_IN { 00562 UINT32 ledNum, period, numTimes; 00563 }; 00564 00565 #define SEND_DATA (1 + (FLASH_LED)) 00566 #define R_SEND_DATA 102 00567 struct SEND_DATA_IN { 00568 UINT32 dataType, auxVal, repBufferFlag, timeout; 00569 }; 00570 struct SEND_DATA_OUT { 00571 UINT32 *dataPtr, dataLength; 00572 }; 00573 #define MIRROR_DATA 0x10 00574 #define ROUTER_DATA 0x11 00575 #define STREAM_DATA 0x12 00576 00577 #define EVENT_DATA 0x20 00578 #define HISTOGRAM_DATA 0x21 00579 #define OCCUPANCY_DATA 0x22 00580 #define FIT_DATA 0x23 00581 00582 /* moduleMask defines the link setup (command & data) for the modules. Like 00583 eventTrapSetup, moduleMask is meant to be sent from the host to the master DSP, 00584 which will transfer its data to the slave DSP(s) if desired. */ 00585 #define MODULE_MASK (1 + (SEND_DATA)) 00586 #define R_MODULE_MASK 101 00587 00588 #if defined(I_AM_SLAVE_DSP) 00589 struct MODULE_MASK_IN { 00590 ModuleMaskData moduleMaskData[N_TOTMODULES]; 00591 }; 00592 #else 00593 struct MODULE_MASK_IN { 00594 UINT32 moduleNum, port, useStructSet, passOn, slvBits; 00595 UINT32 cmdLine, dataLine[4]; 00596 UINT32 cfg, modMask[2], maskType, storage, maskSet; 00597 }; 00598 #endif 00599 00600 /* Send a trigger to the detector electronics. If setTrigger is issued to a 00601 slave DSP, the trigger source is assumed as external (possibly not even issued 00602 by the master DSP); in this case only the current bin & histogram set are set. */ 00603 #define SET_TRIGGER (1 + (MODULE_MASK)) 00604 #define R_SET_TRIGGER 102 00605 struct SET_TRIGGER_IN { 00606 struct CmdList cmdList[2]; 00607 UINT32 slvBits; 00608 UINT16 cmdBuff, preBuilt; 00609 UINT32 chipAddress, bin, set; 00610 UINT32 repetitions, interval; 00611 UINT32 preBuiltDataOffset[2]; 00612 UINT16 incCmd[2]; 00613 UINT32 incData[2]; 00614 00615 }; 00616 00617 /* Serial port definitions; used by several primitives & tasks: */ 00618 #define SP0 0 00619 #define SP1 1 00620 #define SP_BOTH 2 00621 00622 #define START_TASK (1 + (SET_TRIGGER)) 00623 #define R_START_TASK 101 00624 /* Task revision numbers must be updated whenever a task's input parameters 00625 are modified. Revision numbers of the tasks should not exceed 0xff. If 00626 a task has a default position for its memory base (eg. trapTask), that is 00627 defined inside memoryPartitions.h along with the other memory-related 00628 constants. */ 00629 00630 /* master */ 00631 /* Task which controls an entire histogram scan */ 00632 #define R_HISTOGRAM_CTRL_TASK 107 00633 00634 struct XPair { 00635 FLOAT32 x0, delta_x; 00636 }; 00637 struct RangeList { 00638 struct XPair xPair[5]; 00639 }; 00640 00641 #if defined(SCT_ROD) 00642 00643 struct HISTOGRAM_CTRL_TASK_IN { 00644 UINT8 slvBits, port, configRegister[2]; 00645 00646 UINT8 configSctSet, dataSet; 00647 UINT8 groupRangeMap[2]; 00648 00649 UINT8 groupDSPMap[4]; 00650 00651 UINT8 groupSPMap[2]; 00652 UINT8 globalCtrl, syncLevel; 00653 00654 UINT32 *histoBase; 00655 00656 UINT8 arrangement, dataFormat, binSize, unused1; 00657 UINT8 extSetup, dataPath, capture, useRangeList /* unused2 */; 00658 00659 UINT32 repetitions, nBins, bin0; 00660 00661 struct RangeList rangeList[2]; 00662 FLOAT32 *dataPtr[2]; 00663 00664 struct CmdList triggerSequence[2]; 00665 UINT8 incCmd[2]; 00666 UINT8 calLineLoop; 00667 UINT8 distributionToggle; 00668 00669 UINT32 incData[2]; 00670 00671 UINT32 genData[10]; 00672 }; 00673 00674 #elif defined(PIXEL_ROD) 00675 00676 struct HISTOGRAM_CTRL_TASK_IN { 00677 ScanControl scanControl; 00678 }; 00679 #endif 00680 00681 #define MODULE_BASIC 0 00682 #define MODULE_TRIM 1 00683 #define MODULE_ALL 2 00684 00685 #define EXT_SETUP_NONE 0 00686 #define EXT_SETUP_RCF 1 00687 #define EXT_SETUP_ROUTER 2 00688 #define EXT_SETUP_SET 4 00689 #define EXT_SETUP_HISTO 8 00690 #define EXT_SETUP_HTASK 16 00691 00692 #define DATA_PATH_NORMAL 0 00693 #define DATA_PATH_INMEM 1 00694 00695 #define MODULE_GROUP 0 00696 #define ROUTER_DISTRIB 1 00697 00698 #define SYNC_NEWBIN 0 00699 #define SYNC_TOTAL 1 00700 00701 struct HISTOGRAM_CTRL_TASK_OUT { 00702 UINT32 totalTime; 00703 UINT32 slvProcTime[4]; 00704 UINT32 *dataPtr, dataLength; 00705 }; 00706 00707 #define R_MIRROR_TASK 101 00708 struct MIRROR_TASK_IN { 00709 UINT32 slvBits, mirrorFreq, *mirrorBase, 00710 *mirrorSlvBase, mirrorLen; 00711 }; 00712 #define MIRROR_DEFAULT_BASE 0x800000a0 00713 00714 #define R_TRAP_REQ_TASK 101 00715 struct TRAP_REQ_TASK_IN { 00716 UINT32 slvBits, watchFreq; 00717 }; 00718 00719 /* slave */ 00720 #define R_HISTOGRAM_TASK 100 00721 struct HISTOGRAM_TASK_IN { 00722 UINT32 nEvents, controlFlag; /* nEvents can equal COLLECT_FOREVER too. */ 00723 }; 00724 /* control flag settings: */ 00725 #define MASTER_HREG 0 00726 #define LOCAL_INC 1 00727 #define LOCAL_SET_TRIG 2 00728 00729 struct HISTOGRAM_TASK_OUT { 00730 UINT32 nEvents, binsDone; 00731 FLOAT32 avgProcTime; 00732 UINT32 *dataPtr, dataLength; 00733 }; 00734 00735 #define R_TRAP_TASK 100 00736 struct TRAP_TASK_IN { 00737 UINT32 nEvents, reloadInterval, trapType, eventType, 00738 *trapBufferBase, trapBufferLength; 00739 }; 00740 00741 struct TRAP_TASK_OUT { 00742 UINT32 nEvents, dataLen; 00743 UINT32 *bufferBase, bufferLen; 00744 }; 00745 00746 #define R_OCCUPANCY_TASK 100 00747 struct OCCUPANCY_TASK_IN { 00748 UINT32 nEvents, nFilters, splitFlag; 00749 char filter[16]; 00750 }; 00751 00752 #define R_ERROR_TASK 100 00753 struct ERROR_TASK_IN { 00754 UINT32 errorType; 00755 }; 00756 struct ERROR_TASK_OUT { 00757 UINT32 nErrors; 00758 }; 00759 00760 #define R_RESYNCH_TASK 100 00761 struct RESYNCH_TASK_IN { 00762 UINT32 errorType; 00763 }; 00764 00765 /* tasks can have their own specialized output structures, this is a 00766 general one. It is stored as an array of external structures in 00767 the task manager, so that if a task completes & later the data is 00768 requested, it can be supplied. */ 00769 struct GEN_TASK_OUT { 00770 UINT32 *dataPtr, dataLength; 00771 }; 00772 union TASK_STRUCTURES_OUT { 00773 struct HISTOGRAM_CTRL_TASK_OUT histoCtrlTaskOut; 00774 struct HISTOGRAM_TASK_OUT histogramTaskOut; 00775 struct TRAP_TASK_OUT trapTaskOut; 00776 struct ERROR_TASK_OUT errorTaskOut; 00777 struct GEN_TASK_OUT genTaskOut; 00778 }; 00779 00780 /* MAX_NUM_TASKS is the maximum of the two task numbers for master & 00781 slave DSPs. Bad Things can happen if it is not kept up to date */ 00782 #define MAX_NUM_TASKS 5 00783 00784 /* The IDs of the two task sets cannot not exceed 0xff, and must increment by 1. */ 00785 /* master DSP tasks: */ 00786 #define MASTER_TASK_BASE (0x10) 00787 #define HISTOGRAM_CTRL_TASK (MASTER_TASK_BASE) 00788 #define MIRROR_TASK (1+(HISTOGRAM_CTRL_TASK)) 00789 #define TRAP_REQ_TASK (1+(MIRROR_TASK)) 00790 00791 #define LAST_MASTER_TASK (TRAP_REQ_TASK) 00792 #define NUM_MASTER_TASKS ((LAST_MASTER_TASK)-(MASTER_TASK_BASE)+1) 00793 #define ALL_SLAVES 5 00794 00795 /* slave DSP tasks: */ 00796 #define SLAVE_TASK_BASE (0x20) 00797 #define HISTOGRAM_TASK (SLAVE_TASK_BASE) 00798 #define TRAP_TASK (1+(HISTOGRAM_TASK)) 00799 #define OCCUPANCY_TASK (1+(TRAP_TASK)) 00800 #define ERROR_TASK (1+(OCCUPANCY_TASK)) 00801 #define RESYNCH_TASK (1+(ERROR_TASK)) 00802 00803 #define LAST_SLAVE_TASK (RESYNCH_TASK) 00804 #define NUM_SLAVE_TASKS ((LAST_SLAVE_TASK)-(SLAVE_TASK_BASE)+1) 00805 00806 #if defined(I_AM_MASTER_DSP) 00807 #define LAST_TASK (LAST_MASTER_TASK) 00808 #define NUM_TASKS (NUM_MASTER_TASKS) 00809 #define TASK_BASE (MASTER_TASK_BASE) 00810 #elif defined(I_AM_SLAVE_DSP) 00811 #define LAST_TASK (LAST_SLAVE_TASK) 00812 #define NUM_TASKS (NUM_SLAVE_TASKS) 00813 #define TASK_BASE (SLAVE_TASK_BASE) 00814 #endif 00815 00816 union TASK_STRUCTURES_IN { 00817 struct HISTOGRAM_CTRL_TASK_IN histoCtrlTaskIn; 00818 struct MIRROR_TASK_IN mirrorMemoryTaskIn; 00819 struct TRAP_REQ_TASK_IN trapRequestTaskIn; 00820 00821 struct HISTOGRAM_TASK_IN histogramTaskIn; 00822 struct TRAP_TASK_IN trapTaskIn; 00823 struct OCCUPANCY_TASK_IN occupancyTaskIn; 00824 struct ERROR_TASK_IN errorTaskIn; 00825 struct RESYNCH_TASK_IN resynchTaskIn; 00826 }; 00827 00828 struct START_TASK_IN { 00829 UINT32 taskType, taskRevision, priority, completionFlag; 00830 union TASK_STRUCTURES_IN taskStruct; 00831 }; 00832 00833 #define TASK_OPERATION (1 + (START_TASK)) 00834 #define R_TASK_OPERATION 100 00835 struct TASK_OPERATION_IN { 00836 UINT32 taskType, taskOperation, data; 00837 }; 00838 00839 #define TASK_STOP 0 00840 #define TASK_PAUSE 1 00841 #define TASK_RESUME 2 00842 #define TASK_QUERY 3 00843 #define TASK_RESET 4 00844 #define TASK_SETPRIORITY 5 00845 00846 #define TEST (1 + (TASK_OPERATION)) 00847 #define R_TEST 100 00848 struct TEST_IN { 00849 UINT32 dataLen, *dataPtr; 00850 }; 00851 00852 #define WRITE_BUFFER (1 + (TEST)) 00853 #define R_WRITE_BUFFER 101 00854 struct WRITE_BUFFER_IN { 00855 UINT32 buffer; 00856 /*char string[64];*/ 00857 char string[2396]; /* sizeof(union PRIM_PARAMS_UNION) => 2400 bytes. */ 00858 00859 }; 00860 #define WRITE_BUFFER_ERR 0 00861 #define WRITE_BUFFER_INFO 1 00862 #define WRITE_BUFFER_DIAG 2 00863 #define WRITE_BUFFER_XFER 3 00864 00865 #define LAST_COMMON_PRIMITIVE (WRITE_BUFFER) 00866 #define NUM_COMMON_PRIMITIVES ((LAST_COMMON_PRIMITIVE)-(COMMON_PRIMITIVES_BASE)+1) 00867 00868 #if defined(SCT_ROD) 00869 #define COMMON_SCT_PRIMITIVES_BASE 0x800 00870 00871 #ifdef COMMENTED 00872 #define XXX (COMMON_SCT_PRIMITIVES_BASE) 00873 #define LAST_COMMON_SCT_PRIMITIVE (XXX) 00874 #define NUM_COMMON_SCT_PRIMITIVES \ 00875 ((LAST_COMMON_SCT_PRIMITIVE)-(COMMON_SCT_PRIMITIVES_BASE)+1) 00876 #endif 00877 00878 #define NUM_COMMON_SCT_PRIMITIVES 0 00879 00880 #elif defined(PIXEL_ROD) 00881 #define COMMON_PIXEL_PRIMITIVES_BASE 0x800 00882 00883 #ifdef COMMENTED 00884 #define XXX (COMMON_PIXEL_PRIMITIVES_BASE) 00885 #define LAST_COMMON_PIXEL_PRIMITIVE (XXX) 00886 #define NUM_COMMON_PIXEL_PRIMITIVES \ 00887 ((LAST_COMMON_PIXEL_PRIMITIVE)-(COMMON_PIXEL_PRIMITIVES_BASE)+1) 00888 #endif 00889 00890 #define NUM_COMMON_PIXEL_PRIMITIVES 0 00891 00892 #endif 00893 00894 /************************************************************************************ 00895 * Slave DSP primitives go here. 00896 ************************************************************************************/ 00897 #define SLAVE_PRIMITIVES_BASE 0x1000 00898 00899 #define START_EVENT_TRAPPING (SLAVE_PRIMITIVES_BASE) 00900 #define R_START_EVENT_TRAPPING 101 00901 00902 #define STOP_EVENT_TRAPPING (1 + (START_EVENT_TRAPPING)) 00903 #define R_STOP_EVENT_TRAPPING 100 00904 00905 /* Set up & define the histograms. */ 00906 #define HISTOGRAM_SETUP (1 + (STOP_EVENT_TRAPPING)) 00907 #define R_HISTOGRAM_SETUP 107 00908 struct HISTOGRAM_SETUP_IN { 00909 UINT32 *base, nBins; 00910 UINT8 padding[2]; 00911 UINT8 dataType[2]; 00912 UINT8 binSize, unused[3]; 00913 UINT8 opt[4]; 00914 UINT32 validModules[2]; 00915 UINT32 moduleRangeMap[2][2]; 00916 MDAT32 *xPtr[2]; 00917 }; 00918 struct HISTOGRAM_SETUP_OUT { 00919 UINT32 *ctrlPtr, *pulseCtrPtr, *varRangePtr; 00920 }; 00921 00922 /* opt[0]: SCT: The histogram arrangement in memory: block (each 00923 * channel's histogram is in one memory block) or slice 00924 * (the different histogram bins are stacked in memory. 00925 * PXL: TRUE is occupancy histograms are desired 00926 * opt[1]: SCT: The link data format (condensed or expanded). 00927 * PXL: TRUE if time-slice histograms are desired. 00928 * opt[2]: SCT: Unused. 00929 * PXL: TRUE if time-over-threshold histograms are desired. 00930 * opt[3]: SCT: Unused. 00931 * PXL: Indicates the # of events returned per L1A. 00932 */ 00933 00934 /* The default histogram base is defined inside memoryPartitions.h along with 00935 the other memory-related constants. */ 00936 #define HISTOGRAM_BLOCK 0 00937 #define HISTOGRAM_SLICE 1 00938 00939 #define HISTOGRAM_CONDENSED 1 00940 #define HISTOGRAM_FULL 3 00941 00942 #define HISTOGRAM_8BIT 8 00943 #define HISTOGRAM_16BIT 16 00944 #define HISTOGRAM_32BIT 32 00945 00946 #define LAST_SLAVE_PRIMITIVE (HISTOGRAM_SETUP) 00947 #define NUM_SLAVE_PRIMITIVES ((LAST_SLAVE_PRIMITIVE)-(SLAVE_PRIMITIVES_BASE)+1) 00948 00949 #if defined(SCT_ROD) 00950 #define SLAVE_SCT_PRIMITIVES_BASE 0x1800 00951 00952 #ifdef COMMENTED 00953 #define XXX (SLAVE_SCT_PRIMITIVES_BASE) 00954 #define LAST_SLAVE_SCT_PRIMITIVE (XXX) 00955 #define NUM_SLAVE_SCT_PRIMITIVES \ 00956 ((LAST_SLAVE_SCT_PRIMITIVE)-(SLAVE_SCT_PRIMITIVES_BASE)+1) 00957 #endif 00958 00959 #define NUM_SLAVE_SCT_PRIMITIVES 0 00960 00961 #elif defined(PIXEL_ROD) 00962 #define SLAVE_PIXEL_PRIMITIVES_BASE 0x1800 00963 00964 #ifdef COMMENTED 00965 #define XXX (SLAVE_PIXEL_PRIMITIVES_BASE) 00966 #define LAST_SLAVE_PIXEL_PRIMITIVE (XXX) 00967 #define NUM_SLAVE_PIXEL_PRIMITIVES \ 00968 ((LAST_SLAVE_PIXEL_PRIMITIVE)-(SLAVE_PIXEL_PRIMITIVES_BASE)+1) 00969 #endif 00970 00971 #define NUM_SLAVE_PIXEL_PRIMITIVES 0 00972 00973 #endif 00974 00975 /************************************************************************************ 00976 * Master DSP primitives go here. 00977 ************************************************************************************/ 00978 #define MASTER_PRIMITIVES_BASE 0x2000 00979 00980 /* Read or write a block of slave memory. 00981 * - slaveNumber: ID of slave to be accessed 00982 * - readNotWrite = 0 for writing to slaves, != 0 for reading from slaves 00983 * - *slaveAddress: slave reads: source address of the data 00984 * slave writes: destination address of the data 00985 * - *masterAddress: slave reads: destination address of the data; the special value 00986 * DEFAULT puts the data in the body of the reply msg 00987 * just after the RW_SLAVE_MEMORY_OUT structure 00988 * slave writes: source address of the data; the special value 00989 * DEFAULT gets the data from the body of the primitive 00990 * just after the RW_SLAVE_MEMORY_IN structure 00991 * - numWords: in input structure: number of 32 bit words to read or write */ 00992 #define RW_SLAVE_MEMORY (MASTER_PRIMITIVES_BASE) 00993 #define R_RW_SLAVE_MEMORY 100 00994 struct RW_SLAVE_MEMORY_IN { 00995 UINT32 slaveNumber; 00996 UINT32 readNotWrite; 00997 UINT32 *slaveAddress; /* DEFAULT address defined above */ 00998 UINT32 *masterAddress; /* DEFAULT address defined above */ 00999 UINT32 numWords; 01000 }; 01001 01002 /* Transmit serial data to controller FPGA */ 01003 #define TRANS_SERIAL_DATA (1+(RW_SLAVE_MEMORY)) 01004 #define R_TRANS_SERIAL_DATA 100 01005 struct TRANS_DATA { 01006 UINT32 port0Data; /* 32b serial data port 0 */ 01007 UINT32 port1Data; /* 32b serial data port 1 */ 01008 }; 01009 struct TRANS_SERIAL_DATA_IN { 01010 UINT32 captureSerOn; /* Capture module return data in input FIFOs */ 01011 UINT32 streamLen[2], *streams; /* data sets to transmit */ 01012 }; 01013 01014 /* Set DSPINT to start slave. */ 01015 #define START_SLAVE_EXECUTING (1 + (TRANS_SERIAL_DATA)) 01016 #define R_START_SLAVE_EXECUTING 104 01017 struct START_SLAVE_EXECUTING_IN { 01018 UINT32 slaveNumber; 01019 UINT32 commOnOff; 01020 UINT32 slaveType; 01021 UINT32 timeoutInUsec; 01022 }; 01023 struct START_SLAVE_EXECUTING_OUT { 01024 UINT32 slaveNumber; 01025 }; 01026 /* commOnOff options */ 01027 #define SLV_DSP_COMM_OFF 0 01028 #define SLV_DSP_COMM_ON 1 01029 /* slaveType options */ 01030 #define SLV_DSP_UNCONFIGURED 0 01031 #define SLAVE_CALIBRATE 1 01032 #define SLAVE_MONITOR 2 01033 #define SLAVE_ERROR_CHECK 3 01034 #define SLAVE_MEMORY_TEST 4 01035 01036 /* Sets the parameters of the structure rodConfig.slvDspConfig[slvId]. */ 01037 #define CONFIG_SLAVE (1 + (START_SLAVE_EXECUTING)) 01038 #define R_CONFIG_SLAVE 102 01039 struct CONFIG_SLAVE_IN { 01040 UINT32 slaveNumber; 01041 UINT32 commOnOff; 01042 UINT32 slaveType; 01043 }; /* parameters values are same as for START_SLAVE_EXECUTING */ 01044 01045 /* 01046 * Reads or writes a field of a register in the master DSP memory map. 01047 * registerID: ID of the register being polled 01048 * offset: number of lsb in the field, starting with 0 01049 * width: width of the field 01050 * mnemonic symbols for registerID, offset and width are in registerIndices.h 01051 * readNotWrite: 1 for read, 0 for write 01052 * dataIn: data to write for readNotWrite = 0; no significance for readNotWrite = 1 01053 * dataOut: data read for readNotWrite = 1; no significance for readNotWrite = 0 01054 */ 01055 #define RW_REG_FIELD (1 + (CONFIG_SLAVE)) 01056 #define R_RW_REG_FIELD 105 01057 struct RW_REG_FIELD_IN { 01058 UINT32 registerID; 01059 UINT32 offset; 01060 UINT32 width; 01061 UINT32 readNotWrite; 01062 UINT32 dataIn; 01063 }; 01064 struct RW_REG_FIELD_OUT { 01065 UINT32 dataOut; 01066 }; 01067 01068 /* 01069 * Polls a field of a register for a value. A timeout is available. 01070 * registerID: ID of the register being polled 01071 * offset: number of lsb in the field, starting with 0 01072 * width: width of the field 01073 * mnemonic symbols for registerID, offset and width are in registerIndices.h 01074 * desiredValue: value of the defined field to poll for 01075 * timeoutInUsec: timeout period in microseconds 01076 * found: indicates whether 'desiredValue' was found within 'timeoutInUsec' 01077 */ 01078 #define POLL_REG_FIELD (1 + (RW_REG_FIELD)) 01079 #define R_POLL_REG_FIELD 105 01080 struct POLL_REG_FIELD_IN { 01081 UINT32 registerID; 01082 UINT32 offset; 01083 UINT32 width; 01084 UINT32 desiredValue; 01085 UINT32 timeoutInUsec; 01086 }; 01087 struct POLL_REG_FIELD_OUT { 01088 UINT32 found; 01089 }; 01090 01091 /* Reads/writes some number of words from/to one of the FIFOs on the ROD. 01092 * - fifoID: INPUT_MEM, DEBUG_MEM or EVENT_MEM 01093 * - bank: BANK_A, BANK_B or (EVENT_MEM only) BANK_C 01094 * - readNotWrite: 1 for read, 0 for write 01095 * - numElements: number of fifo entries to read or write; NOTE: no packing, eg 01096 * to write 20 elements to INPUT_MEM BANK_A requires 40 32b data words 01097 * to write 20 elements to EVENT_MEM BANK_C requires 20 32b data words 01098 * 20 elements read from EVENT_MEM BANK_C will occupy 20 32b data words 01099 * - *dataBaseAdr: for readNotWrite = 0 source address of data for the FIFO 01100 * = 1 destination address for data from the FIFO 01101 * if *dataBaseAdr = DEFAULT 01102 * readNotWrite = 0: data is supplied with the RW_FIFO primitive after *data 01103 * readNotWrite = 1: data is written to the reply message body after bytesXfrd 01104 * There is also a scratch space in SDRAM at SCRATCH_BASE (memoryPartitions.h) 01105 * - bytesXfrd: Number of bytes read or written 01106 */ 01107 #define RW_FIFO (1 + (POLL_REG_FIELD)) 01108 #define R_RW_FIFO 104 01109 struct RW_FIFO_IN { 01110 UINT32 fifoId; 01111 UINT32 bank; 01112 UINT32 readNotWrite; 01113 UINT32 numElements; 01114 UINT32 *dataBaseAdr; /* DEFAULT value defined above */ 01115 }; 01116 struct RW_FIFO_OUT { 01117 UINT32 bytesXfrd; 01118 }; 01119 #define INPUT_MEM 0x0 /* values of fifoID */ 01120 #define DEBUG_MEM 0x1 01121 #define EVENT_MEM 0x2 01122 #define TIM_MEM 0x3 01123 #define BANK_A 0x0 /* values of bank; ignored for TIM_MEM */ 01124 #define BANK_B 0x1 01125 #define BANK_C 0x2 /* EVENT_MEM only */ 01126 01127 /* 01128 * Send a primitive list to a slave DSP. 01129 * slaveNumber: ID of slave DSP to recieve the list. 01130 * listLength: number of 32 bit words in the list. 01131 * *slavePrimList: Address of start of source data for the list. 01132 * - *slavePrimList = DEFAULT indicates that the slave primitive list is stored in 01133 * the body of this SEND_SLAVE_LIST primtive starting just after the last 01134 * SEND_SLAVE_LIST_IN structure element. 01135 * *slaveRepData: Address where master should put slave reply data if the 01136 * START_SLAVE_LIST primitive is executed with getSlaveReply != 0. 01137 * - *slaveRepData = DEFAULT indicates that the slave reply list should be stored 01138 * in the body of a reply message to the START_SLAVE_LIST primtive. 01139 */ 01140 #define SEND_SLAVE_LIST (1 + (RW_FIFO)) 01141 #define R_SEND_SLAVE_LIST 103 01142 struct SEND_SLAVE_LIST_IN { 01143 UINT32 slaveNumber; 01144 UINT32 listLength; 01145 UINT32 *slavePrimList; /* DEFAULT value defined above */ 01146 UINT32 *slaveRepData; /* DEFAULT value defined above */ 01147 }; 01148 01149 /* 01150 * Start a slave DSP executing its primitive list by setting its inListRdy bit. 01151 * slaveNumber: ID of slave DSP to execute list 01152 * pauseMasterList != 0 if master DSP list execution pauses while slave executes list 01153 * getSlaveReply != 0 if the master should read the slave reply data 01154 */ 01155 #define START_SLAVE_LIST (1 + (SEND_SLAVE_LIST)) 01156 #define R_START_SLAVE_LIST 103 01157 struct START_SLAVE_LIST_IN { 01158 UINT32 slaveNumber; 01159 UINT32 pauseMasterList; 01160 UINT32 getSlaveReply; 01161 }; 01162 01163 /* pause, resume or abort a slave list */ 01164 #define SLAVE_LIST_OP (1 + (START_SLAVE_LIST)) 01165 #define R_SLAVE_LIST_OP 101 01166 struct SLAVE_LIST_OP_IN { 01167 UINT32 slaveNumber; 01168 UINT32 listOp; 01169 }; 01170 #define LIST_PAUSE 0 01171 #define LIST_RESUME 1 01172 #define LIST_ABORT 2 01173 01174 /* Build & send a command stream to the detector electronics. sendData will ship 01175 a command stream back to the VME host. */ 01176 #define BUILD_STREAM (1 + (SLAVE_LIST_OP)) 01177 #define R_BUILD_STREAM 102 01178 struct BUILD_STREAM_IN { 01179 struct CmdList cmdList; 01180 UINT32 cmdBuff, reset, chip, fibre; 01181 UINT32 dataLen; /* Length of the extra data, in bits. */ 01182 UINT32 *data; /* Start of the data for a command with large amounts of 01183 data (masks & some pixel commands). */ 01184 }; 01185 01186 #define SEND_STREAM (1 + (BUILD_STREAM)) 01187 #define R_SEND_STREAM 100 01188 struct SEND_STREAM_IN { 01189 UINT32 cmdBuff, captureSerOn; 01190 }; 01191 01192 /* configure a module, or send it's data (resident in memory) to control links. 01193 For input data, the pointer to configData is the start. */ 01194 #define RW_MODULE_DATA (1 + (SEND_STREAM)) 01195 #define R_RW_MODULE_DATA 102 01196 struct RW_MODULE_DATA_IN { 01197 UINT32 readNotWrite, structId, moduleNum; 01198 Module *configData; 01199 }; 01200 struct RW_MODULE_DATA_OUT { 01201 Module configData; 01202 }; 01203 #define PHYSICS_MODULE_CONFIG 0 01204 #define SCAN_MODULE_CONFIG 1 01205 #define SPARE_MODULE_CONFIG 2 01206 #define N_MODULE_CONFIG_SETS ((SPARE_MODULE_CONFIG) -(PHYSICS_MODULE_CONFIG) +1) 01207 01208 01209 #define SEND_CONFIG (1 + (RW_MODULE_DATA)) 01210 #define R_SEND_CONFIG 105 01211 struct SEND_CONFIG_IN { 01212 UINT32 port, captureSerOn, moduleNum[2], chipNum, 01213 setLinks, restore, structId, groupId, dataType, 01214 activeOnly, enableDataTaking; 01215 }; 01216 01217 #define NO_CONFIG_LOOP 0 01218 #define NORMAL_CONFIG_LOOP 1 01219 #define OFF_ROD_CONFIG_LOOP 2 01220 01221 #if defined(SCT_ROD) 01222 #define CONFIG_MODULE_BASIC 0 01223 #define CONFIG_MODULE_TRIM 1 01224 #define CONFIG_MODULE_ALL 2 01225 01226 #elif defined(PIXEL_ROD) 01227 //Pixel additive bitwise definitions; the 1st 14 correspond to the bit 01228 //definitions in the pixel control register. 01229 #define CONFIG_MODULE_ENABLE 0 01230 #define CONFIG_MODULE_SELECT 1 01231 #define CONFIG_MODULE_PREAMP 2 01232 #define CONFIG_MODULE_HITBUS 3 01233 01234 #define CONFIG_MODULE_TDAC_0 4 01235 #define CONFIG_MODULE_TDAC_1 5 01236 #define CONFIG_MODULE_TDAC_2 6 01237 #define CONFIG_MODULE_TDAC_3 7 01238 #define CONFIG_MODULE_TDAC_4 8 01239 01240 #define CONFIG_MODULE_FDAC_0 9 01241 #define CONFIG_MODULE_FDAC_1 10 01242 #define CONFIG_MODULE_FDAC_2 11 01243 #define CONFIG_MODULE_FDAC_3 12 01244 #define CONFIG_MODULE_FDAC_4 13 01245 01246 #define CONFIG_MODULE_GLOBAL 16 01247 #define CONFIG_MODULE_CONTROL 17 01248 #define CONFIG_MODULE_TDAC 18 01249 #define CONFIG_MODULE_FDAC 19 01250 01251 #define CONFIG_MODULE_SCAN_TDAC 20 01252 #define CONFIG_MODULE_SCAN_FDAC 21 01253 #define CONFIG_MODULE_MCC 22 01254 #define CONFIG_MODULE_ALL 23 01255 #endif 01256 01257 01258 #define ALL_MODULES 0xfe 01259 #define NO_MODULE 0xff 01260 01261 #define MODULE_GROUP_0 0 01262 #define MODULE_GROUP_1 1 01263 #define MODULE_GROUP_2 2 01264 #define MODULE_GROUP_3 3 01265 #define MODULE_GROUP_4 4 01266 #define MODULE_GROUP_5 5 01267 #define MODULE_GROUP_6 6 01268 #define MODULE_GROUP_7 7 01269 01270 #define MODULE_GROUP_ALL 8 01271 #define N_MODULE_GROUPS (MODULE_GROUP_ALL) 01272 01273 #define DSP_RESET (1 + (SEND_CONFIG)) 01274 #define R_DSP_RESET 100 01275 struct DSP_RESET_IN { 01276 UINT32 slvBits, forceSync, nAttempts, timeOut; 01277 }; 01278 01279 #define SET_ROD_MODE (1 + (DSP_RESET)) 01280 #define R_SET_ROD_MODE 101 01281 struct SET_ROD_MODE_IN { 01282 UINT32 mode, flag, fifoSetup, nBits, delay, evtsPerL1A, message; 01283 }; 01284 01285 #define RW_MODULE_VARIABLE (1 + (SET_ROD_MODE)) 01286 #define R_RW_MODULE_VARIABLE 101 01287 struct RW_MODULE_VARIABLE_IN { 01288 UINT32 read, structId, groupId, module, chip, 01289 varType, dataLen; 01290 MDAT32 *data; 01291 }; 01292 struct RW_MODULE_VARIABLE_OUT { 01293 UINT32 dataLen; 01294 MDAT32 *data; 01295 }; 01296 01297 #define MVAR_GROUP_ID 100 01298 #define MVAR_ACTIVE 101 01299 #define MVAR_SELECT 102 01300 01301 01302 #define RW_BOC_DATA (1 + (RW_MODULE_VARIABLE)) 01303 #define R_RW_BOC_DATA 100 01304 struct RW_BOC_DATA_IN { 01305 UINT32 read, sendToBoc, dataLen, *data; 01306 }; 01307 struct RW_BOC_DATA_OUT { 01308 BOCConfig bocCfgData; 01309 }; 01310 01311 01312 #define BOC_HISTOGRAM (1 + (RW_BOC_DATA)) 01313 #define R_BOC_HISTOGRAM 100 01314 struct BOC_HISTOGRAM_IN { 01315 UINT32 numSamples, numLoops; 01316 }; 01317 struct BOC_HISTOGRAM_OUT { 01318 UINT32 histo[96][2]; 01319 }; 01320 01321 #define LAST_MASTER_PRIMITIVE (BOC_HISTOGRAM) 01322 #define NUM_MASTER_PRIMITIVES ((LAST_MASTER_PRIMITIVE)-(MASTER_PRIMITIVES_BASE)+1) 01323 01324 01325 #if defined(SCT_ROD) 01326 #define MASTER_SCT_PRIMITIVES_BASE 0x2800 01327 01328 #ifdef COMMENTED 01329 #define XXX (MASTER_SCT_PRIMITIVES_BASE) 01330 #define LAST_MASTER_SCT_PRIMITIVE (XXX) 01331 #define NUM_MASTER_SCT_PRIMITIVES \ 01332 ((LAST_MASTER_SCT_PRIMITIVE)-(MASTER_SCT_PRIMITIVES_BASE)+1) 01333 #endif 01334 01335 #define NUM_MASTER_SCT_PRIMITIVES 0 01336 01337 #elif defined(PIXEL_ROD) 01338 #define MASTER_PIXEL_PRIMITIVES_BASE 0x2800 01339 01340 #define TEST_GLOBAL_REG (MASTER_PIXEL_PRIMITIVES_BASE) 01341 #define R_TEST_GLOBAL_REG 112 01342 struct TEST_GLOBAL_REG_IN { 01343 UINT32 structId; 01344 UINT32 moduleId; 01345 UINT32 FEIndex; 01346 }; 01347 struct TEST_GLOBAL_REG_OUT { 01348 UINT32 testResult; 01349 UINT32 dataLen; 01350 MDAT32 *data; 01351 }; 01352 01353 #define LAST_MASTER_PIXEL_PRIMITIVE (TEST_GLOBAL_REG) 01354 #define NUM_MASTER_PIXEL_PRIMITIVES \ 01355 ((LAST_MASTER_PIXEL_PRIMITIVE)-(MASTER_PIXEL_PRIMITIVES_BASE)+1) 01356 #endif 01357 01358 01359 #if defined(SCT_ROD) 01360 #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES) \ 01361 +(NUM_SLAVE_PRIMITIVES) \ 01362 +(NUM_MASTER_PRIMITIVES) \ 01363 +(NUM_COMMON_SCT_PRIMITIVES) \ 01364 +(NUM_SLAVE_SCT_PRIMITIVES) \ 01365 +(NUM_MASTER_SCT_PRIMITIVES) ) 01366 01367 #elif defined(PIXEL_ROD) 01368 #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES) \ 01369 +(NUM_SLAVE_PRIMITIVES) \ 01370 +(NUM_MASTER_PRIMITIVES) \ 01371 +(NUM_COMMON_PIXEL_PRIMITIVES) \ 01372 +(NUM_SLAVE_PIXEL_PRIMITIVES) \ 01373 +(NUM_MASTER_PIXEL_PRIMITIVES) ) 01374 01375 #else 01376 #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES) \ 01377 +(NUM_SLAVE_PRIMITIVES) \ 01378 +(NUM_MASTER_PRIMITIVES) ) 01379 01380 #endif 01381 01382 /************************************************************************************ 01383 * Primitive function prototypes (not needed by the host processor). 01384 ************************************************************************************/ 01385 #if (defined(I_AM_MASTER_DSP) || defined(I_AM_SLAVE_DSP)) 01386 INT32 noPrimitive(struct PRIM_DATA *); 01387 01388 INT32 echo(struct PRIM_DATA *); 01389 INT32 setErrMsgMask(struct PRIM_DATA *); 01390 INT32 pauseList(struct PRIM_DATA *); 01391 INT32 eventTrapSetup(struct PRIM_DATA *); 01392 INT32 setMemory(struct PRIM_DATA *); 01393 INT32 copyMemory(struct PRIM_DATA *); 01394 INT32 memoryTest(struct PRIM_DATA *); 01395 INT32 setLed(struct PRIM_DATA *); 01396 INT32 flashLed(struct PRIM_DATA *); 01397 INT32 sendData(struct PRIM_DATA *); 01398 INT32 moduleMask(struct PRIM_DATA *); 01399 INT32 setTrigger(struct PRIM_DATA *); 01400 INT32 startTask(struct PRIM_DATA *); 01401 INT32 taskOperation(struct PRIM_DATA *); 01402 INT32 test(struct PRIM_DATA *); 01403 INT32 writeBuffer(struct PRIM_DATA *); 01404 01405 #if defined(SCT_ROD) 01406 #elif defined(PIXEL_ROD) 01407 #endif 01408 01409 INT32 startEventTrapping(struct PRIM_DATA *); 01410 INT32 stopEventTrapping(struct PRIM_DATA *); 01411 INT32 histogramSetup(struct PRIM_DATA *); 01412 01413 #if defined(SCT_ROD) 01414 #elif defined(PIXEL_ROD) 01415 #endif 01416 01417 INT32 rwSlaveMemory(struct PRIM_DATA *); 01418 INT32 transSerialData (struct PRIM_DATA *); 01419 INT32 startSlaveExecuting(struct PRIM_DATA *); 01420 INT32 configSlave(struct PRIM_DATA *); 01421 INT32 rwRegField(struct PRIM_DATA *); 01422 INT32 pollRegField(struct PRIM_DATA *); 01423 INT32 rwFifo(struct PRIM_DATA *); 01424 INT32 sendSlaveList(struct PRIM_DATA *); 01425 INT32 startSlaveList(struct PRIM_DATA *); 01426 INT32 slaveListOp(struct PRIM_DATA *); 01427 INT32 buildStream(struct PRIM_DATA *); 01428 INT32 sendStream(struct PRIM_DATA *); 01429 INT32 rwModuleData(struct PRIM_DATA *); 01430 INT32 sendConfig(struct PRIM_DATA *); 01431 INT32 dspReset(struct PRIM_DATA *); 01432 INT32 setRodMode(struct PRIM_DATA *); 01433 INT32 rwModuleVariable(struct PRIM_DATA *); 01434 INT32 rwBocData(struct PRIM_DATA *); 01435 INT32 BOChistogram(struct PRIM_DATA *primData); 01436 /* INT32 configBoc(struct PRIM_DATA *); */ 01437 01438 #if defined(SCT_ROD) 01439 #elif defined(PIXEL_ROD) 01440 INT32 testGlobalReg(struct PRIM_DATA *); 01441 #endif 01442 01443 #endif /* primitive parameters definition block */ 01444 01445 #endif