Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

primParams.h

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          103
00567     struct SEND_DATA_IN {
00568         UINT32 dataType, auxVal, repBufferFlag, timeout;
00569     };
00570     struct SEND_DATA_OUT {
00571         void   *dataPtr;
00572         UINT32 dataLength;
00573     };
00574     #define MIRROR_DATA    0x10
00575     #define ROUTER_DATA    0x11
00576     #define STREAM_DATA    0x12
00577 
00578     #define EVENT_DATA     0x20
00579     #define HISTOGRAM_DATA 0x21
00580     #define OCCUPANCY_DATA 0x22
00581     #define FIT_DATA       0x23
00582     #define BIN_DATA       0x24
00583 
00584 /* moduleMask defines the link setup (command & data) for the modules. Like
00585    eventTrapSetup, moduleMask is meant to be sent from the host to the master DSP,
00586    which will transfer its data to the slave DSP(s) if desired. */
00587 #define MODULE_MASK         (1 + (SEND_DATA))
00588     #define R_MODULE_MASK       101
00589 
00590     #if defined(I_AM_SLAVE_DSP)
00591         struct MODULE_MASK_IN {
00592             ModuleMaskData moduleMaskData[N_TOTMODULES];
00593         };
00594     #else
00595         struct MODULE_MASK_IN {
00596             UINT32 moduleNum, port, useStructSet, passOn, slvBits;
00597             UINT32 cmdLine, dataLine[4];
00598             UINT32 cfg, modMask[2], maskType, storage, maskSet; 
00599         };
00600     #endif
00601 
00602 /* Send a trigger to the detector electronics. If setTrigger is issued to a
00603    slave DSP, the trigger source is assumed as external (possibly not even issued
00604    by the master DSP); in this case only the current bin & histogram set are set. */
00605 #define SET_TRIGGER          (1 + (MODULE_MASK))
00606 #define R_SET_TRIGGER        102
00607     struct SET_TRIGGER_IN {
00608         struct  CmdList cmdList[2];
00609         UINT32  slvBits;
00610         UINT16  cmdBuff, preBuilt;
00611         UINT32  chipAddress, bin, set;
00612         UINT32  repetitions, interval;
00613         UINT32  preBuiltDataOffset[2];
00614         UINT16  incCmd[2];
00615         UINT32  incData[2];
00616 
00617     };
00618 
00619 /* Serial port definitions; used by several primitives & tasks: */
00620 #define SP0      0
00621 #define SP1      1
00622 #define SP_BOTH  2
00623 
00624 #define START_TASK           (1 + (SET_TRIGGER))
00625 #define R_START_TASK         101
00626     /* Task revision numbers must be updated whenever a task's input parameters
00627        are modified. Revision numbers of the tasks should not exceed 0xff. If
00628        a task has a default position for its memory base (eg. trapTask), that is
00629        defined inside memoryPartitions.h along with the other memory-related
00630        constants. */
00631 
00632     /* master */
00633 /* Task which controls an entire histogram scan */
00634     #define R_HISTOGRAM_CTRL_TASK   107
00635 
00636         struct XPair {
00637             FLOAT32 x0, delta_x;
00638         };
00639         struct RangeList {
00640             struct XPair xPair[5]; 
00641         };
00642 
00643     #if defined(SCT_ROD)
00644 
00645     struct  HISTOGRAM_CTRL_TASK_IN {
00646         UINT8   slvBits, port, configRegister[2];
00647 
00648         UINT8   configSctSet, dataSet;
00649         UINT8   groupRangeMap[2];
00650 
00651         UINT8   groupDSPMap[4];
00652 
00653         UINT8   groupSPMap[2];
00654         UINT8   globalCtrl, syncLevel;
00655 
00656         UINT32  *histoBase;
00657 
00658         UINT8   doChipOcc, dataFormat, binSize, unused1;
00659         UINT8   extSetup, dataPath, capture, useRangeList /* unused2 */;
00660 
00661         UINT32  repetitions, nBins, bin0;
00662 
00663         struct  RangeList rangeList[2];
00664         FLOAT32 *dataPtr[2];
00665 
00666         struct  CmdList triggerSequence[2];
00667         UINT8   incCmd[2];
00668         UINT8   calLineLoop;
00669         UINT8   distributionToggle;
00670 
00671         UINT32  incData[2];
00672 
00673         UINT32  genData[10];
00674     };
00675 
00676     #elif defined(PIXEL_ROD)
00677 
00678         struct  HISTOGRAM_CTRL_TASK_IN {
00679             ScanControl scanControl;
00680         };
00681     #endif
00682 
00683     #define MODULE_BASIC  0
00684     #define MODULE_TRIM   1
00685     #define MODULE_ALL    2
00686 
00687     #define EXT_SETUP_NONE    0
00688     #define EXT_SETUP_RCF     1 
00689     #define EXT_SETUP_ROUTER  2
00690     #define EXT_SETUP_SET     4
00691     #define EXT_SETUP_HISTO   8 
00692     #define EXT_SETUP_HTASK   16 
00693 
00694     #define DATA_PATH_NORMAL  0
00695     #define DATA_PATH_INMEM   1
00696 
00697     #define MODULE_GROUP   0
00698     #define ROUTER_DISTRIB 1
00699 
00700     #define SYNC_NEWBIN    0
00701     #define SYNC_TOTAL     1
00702 
00703     struct HISTOGRAM_CTRL_TASK_OUT {
00704         UINT32  totalTime;
00705         UINT32  slvProcTime[4];
00706         UINT32  *dataPtr, dataLength;
00707     };
00708 
00709     #define R_MIRROR_TASK     101
00710     struct MIRROR_TASK_IN {
00711         UINT32 slvBits, mirrorFreq, *mirrorBase,
00712                *mirrorSlvBase, mirrorLen;
00713     };
00714     #define MIRROR_DEFAULT_BASE 0x800000a0
00715 
00716     #define R_TRAP_REQ_TASK   101
00717     struct TRAP_REQ_TASK_IN {
00718         UINT32 slvBits, watchFreq;
00719     };
00720 
00721     /* slave */
00722     #define R_HISTOGRAM_TASK  100
00723     struct HISTOGRAM_TASK_IN {
00724         UINT32 nEvents, controlFlag;  /* nEvents can equal COLLECT_FOREVER too. */
00725     };
00726     /* control flag settings: */
00727     #define MASTER_HREG     0
00728     #define LOCAL_INC       1
00729     #define LOCAL_SET_TRIG  2
00730 
00731     struct HISTOGRAM_TASK_OUT {
00732         UINT32  nEvents, binsDone;
00733         FLOAT32 avgProcTime;
00734         UINT32  *dataPtr, dataLength;
00735     };
00736 
00737     #define R_TRAP_TASK       100
00738     struct TRAP_TASK_IN {
00739         UINT32 nEvents, reloadInterval, trapType, eventType,
00740                *trapBufferBase, trapBufferLength;
00741     };
00742 
00743     struct TRAP_TASK_OUT {
00744         UINT32  nEvents, dataLen;
00745         UINT32  *bufferBase, bufferLen;
00746     };
00747 
00748     #define R_OCCUPANCY_TASK  100
00749     struct OCCUPANCY_TASK_IN {
00750         UINT32 nEvents, nFilters, splitFlag;
00751         char   filter[16];
00752     };
00753 
00754     #define R_ERROR_TASK      100
00755     struct ERROR_TASK_IN {
00756         UINT32 errorType;
00757     };
00758     struct ERROR_TASK_OUT {
00759         UINT32 nErrors;
00760     };
00761 
00762     #define R_RESYNCH_TASK    100
00763     struct RESYNCH_TASK_IN {
00764         UINT32 errorType;
00765     };
00766 
00767     /* tasks can have their own specialized output structures, this is a
00768        general one. It is stored as an array of external structures in
00769        the task manager, so that if a task completes & later the data is
00770        requested, it can be supplied. */
00771     struct GEN_TASK_OUT {
00772         UINT32 *dataPtr, dataLength;
00773     };
00774     union TASK_STRUCTURES_OUT {
00775         struct HISTOGRAM_CTRL_TASK_OUT  histoCtrlTaskOut;
00776         struct HISTOGRAM_TASK_OUT       histogramTaskOut;
00777         struct TRAP_TASK_OUT            trapTaskOut;
00778         struct ERROR_TASK_OUT           errorTaskOut;
00779         struct GEN_TASK_OUT             genTaskOut;
00780     };
00781 
00782     /* MAX_NUM_TASKS is the maximum of the two task numbers for master &
00783        slave DSPs. Bad Things can happen if it is not kept up to date */
00784     #define MAX_NUM_TASKS   5
00785 
00786     /* The IDs of the two task sets cannot not exceed 0xff, and must increment by 1. */
00787     /* master DSP tasks: */
00788     #define MASTER_TASK_BASE     (0x10)
00789     #define HISTOGRAM_CTRL_TASK  (MASTER_TASK_BASE)
00790     #define MIRROR_TASK          (1+(HISTOGRAM_CTRL_TASK))
00791     #define TRAP_REQ_TASK        (1+(MIRROR_TASK))
00792 
00793     #define LAST_MASTER_TASK  (TRAP_REQ_TASK)
00794     #define NUM_MASTER_TASKS  ((LAST_MASTER_TASK)-(MASTER_TASK_BASE)+1)
00795             #define ALL_SLAVES      5
00796 
00797     /* slave DSP tasks: */
00798     #define SLAVE_TASK_BASE  (0x20)
00799     #define HISTOGRAM_TASK  (SLAVE_TASK_BASE)
00800     #define TRAP_TASK       (1+(HISTOGRAM_TASK))
00801     #define OCCUPANCY_TASK  (1+(TRAP_TASK))
00802     #define ERROR_TASK      (1+(OCCUPANCY_TASK))
00803     #define RESYNCH_TASK    (1+(ERROR_TASK))
00804 
00805     #define LAST_SLAVE_TASK  (RESYNCH_TASK)
00806     #define NUM_SLAVE_TASKS  ((LAST_SLAVE_TASK)-(SLAVE_TASK_BASE)+1)
00807 
00808     #if   defined(I_AM_MASTER_DSP)
00809         #define LAST_TASK  (LAST_MASTER_TASK)
00810         #define NUM_TASKS  (NUM_MASTER_TASKS)
00811         #define TASK_BASE  (MASTER_TASK_BASE)
00812     #elif defined(I_AM_SLAVE_DSP)
00813         #define LAST_TASK  (LAST_SLAVE_TASK)
00814         #define NUM_TASKS  (NUM_SLAVE_TASKS)
00815         #define TASK_BASE  (SLAVE_TASK_BASE)
00816     #endif
00817 
00818     union TASK_STRUCTURES_IN {
00819         struct HISTOGRAM_CTRL_TASK_IN  histoCtrlTaskIn;
00820         struct MIRROR_TASK_IN          mirrorMemoryTaskIn;
00821         struct TRAP_REQ_TASK_IN        trapRequestTaskIn;
00822 
00823         struct HISTOGRAM_TASK_IN  histogramTaskIn;
00824         struct TRAP_TASK_IN       trapTaskIn;
00825         struct OCCUPANCY_TASK_IN  occupancyTaskIn;
00826         struct ERROR_TASK_IN      errorTaskIn;
00827         struct RESYNCH_TASK_IN    resynchTaskIn;
00828     };
00829 
00830     struct START_TASK_IN {
00831         UINT32 taskType, taskRevision, priority, completionFlag;
00832         union  TASK_STRUCTURES_IN  taskStruct;
00833     };
00834 
00835 #define TASK_OPERATION      (1 + (START_TASK))
00836 #define R_TASK_OPERATION         100
00837     struct TASK_OPERATION_IN {
00838         UINT32 taskType, taskOperation, data;
00839     };
00840 
00841 #define TASK_STOP         0
00842 #define TASK_PAUSE        1
00843 #define TASK_RESUME       2
00844 #define TASK_QUERY        3
00845 #define TASK_RESET        4
00846 #define TASK_SETPRIORITY  5
00847 
00848 #define TEST         (1 + (TASK_OPERATION))
00849 #define R_TEST              100
00850     struct TEST_IN {
00851         UINT32 dataLen, *dataPtr;
00852     };
00853 
00854 #define WRITE_BUFFER         (1 + (TEST))
00855 #define R_WRITE_BUFFER         101
00856     struct WRITE_BUFFER_IN {
00857         UINT32 buffer;
00858         /*char string[64];*/
00859         char string[2396];  /* sizeof(union PRIM_PARAMS_UNION) => 2400 bytes. */
00860 
00861     };
00862     #define WRITE_BUFFER_ERR  0
00863     #define WRITE_BUFFER_INFO 1
00864     #define WRITE_BUFFER_DIAG 2
00865     #define WRITE_BUFFER_XFER 3
00866 
00867 #define LAST_COMMON_PRIMITIVE   (WRITE_BUFFER)
00868 #define NUM_COMMON_PRIMITIVES   ((LAST_COMMON_PRIMITIVE)-(COMMON_PRIMITIVES_BASE)+1)
00869 
00870 #if   defined(SCT_ROD)
00871     #define COMMON_SCT_PRIMITIVES_BASE 0x800
00872 
00873     #ifdef COMMENTED
00874     #define XXX (COMMON_SCT_PRIMITIVES_BASE)
00875     #define LAST_COMMON_SCT_PRIMITIVE   (XXX)
00876     #define NUM_COMMON_SCT_PRIMITIVES   \
00877         ((LAST_COMMON_SCT_PRIMITIVE)-(COMMON_SCT_PRIMITIVES_BASE)+1)
00878     #endif
00879 
00880     #define NUM_COMMON_SCT_PRIMITIVES  0
00881 
00882 #elif defined(PIXEL_ROD)
00883     #define COMMON_PIXEL_PRIMITIVES_BASE 0x800
00884 
00885     #ifdef COMMENTED
00886     #define XXX (COMMON_PIXEL_PRIMITIVES_BASE)
00887     #define LAST_COMMON_PIXEL_PRIMITIVE   (XXX)
00888     #define NUM_COMMON_PIXEL_PRIMITIVES   \
00889         ((LAST_COMMON_PIXEL_PRIMITIVE)-(COMMON_PIXEL_PRIMITIVES_BASE)+1)
00890     #endif
00891 
00892     #define NUM_COMMON_PIXEL_PRIMITIVES  0
00893 
00894 #endif
00895 
00896 /************************************************************************************
00897  *                             Slave DSP primitives go here.
00898  ************************************************************************************/
00899 #define SLAVE_PRIMITIVES_BASE  0x1000
00900 
00901 #define START_EVENT_TRAPPING   (SLAVE_PRIMITIVES_BASE)
00902 #define R_START_EVENT_TRAPPING       101
00903 
00904 #define STOP_EVENT_TRAPPING    (1 + (START_EVENT_TRAPPING))
00905 #define R_STOP_EVENT_TRAPPING        100
00906 
00907 /* Set up & define the histograms. */
00908 #define HISTOGRAM_SETUP        (1 + (STOP_EVENT_TRAPPING))
00909 #define R_HISTOGRAM_SETUP            108
00910     struct HISTOGRAM_SETUP_IN {
00911         UINT32  *base;
00912         UINT32  nBins;
00913         UINT32  binSize;
00914         UINT32  routineType;
00915         UINT32  dataType[2];
00916         UINT32  opt[4];
00917 
00918         UINT32  validModules[2];
00919         UINT32  moduleRangeMap[2][2];
00920         MDAT32 *xPtr[2];
00921     };
00922     struct HISTOGRAM_SETUP_OUT {
00923         UINT32 *base, size;
00924         UINT32 *ctrlPtr, *binCtr, *varRangePtr;
00925     };
00926 
00927     /* The default histogram base is defined inside memoryPartitions.h along with
00928        the other memory-related constants. */
00929     #define HISTOGRAM_CONDENSED 1
00930     #define HISTOGRAM_FULL      3
00931 
00932     #define HISTOGRAM_8BIT      8
00933     #define HISTOGRAM_16BIT     16
00934     #define HISTOGRAM_32BIT     32
00935     
00936     #define HISTO_ROUTINE_C     0
00937     #define HISTO_ROUTINE_ASM   1
00938 
00939 
00940 #define LAST_SLAVE_PRIMITIVE    (HISTOGRAM_SETUP)
00941 #define NUM_SLAVE_PRIMITIVES   ((LAST_SLAVE_PRIMITIVE)-(SLAVE_PRIMITIVES_BASE)+1)
00942 
00943 #if   defined(SCT_ROD)
00944     #define SLAVE_SCT_PRIMITIVES_BASE 0x1800
00945 
00946     #ifdef COMMENTED
00947     #define XXX (SLAVE_SCT_PRIMITIVES_BASE)
00948     #define LAST_SLAVE_SCT_PRIMITIVE   (XXX)
00949     #define NUM_SLAVE_SCT_PRIMITIVES   \
00950         ((LAST_SLAVE_SCT_PRIMITIVE)-(SLAVE_SCT_PRIMITIVES_BASE)+1)
00951     #endif
00952 
00953     #define NUM_SLAVE_SCT_PRIMITIVES  0
00954 
00955 #elif defined(PIXEL_ROD)
00956     #define SLAVE_PIXEL_PRIMITIVES_BASE 0x1800
00957 
00958     #ifdef COMMENTED
00959     #define XXX (SLAVE_PIXEL_PRIMITIVES_BASE)
00960     #define LAST_SLAVE_PIXEL_PRIMITIVE   (XXX)
00961     #define NUM_SLAVE_PIXEL_PRIMITIVES   \
00962         ((LAST_SLAVE_PIXEL_PRIMITIVE)-(SLAVE_PIXEL_PRIMITIVES_BASE)+1)
00963     #endif
00964 
00965     #define NUM_SLAVE_PIXEL_PRIMITIVES  0
00966 
00967 #endif
00968 
00969 /************************************************************************************
00970  *                          Master DSP primitives go here.
00971  ************************************************************************************/
00972 #define MASTER_PRIMITIVES_BASE 0x2000
00973 
00974 /* Read or write a block of slave memory.
00975  * - slaveNumber: ID of slave to be accessed
00976  * - readNotWrite = 0 for writing to slaves, != 0 for reading from slaves
00977  * - *slaveAddress: slave reads: source address of the data
00978  *                  slave writes: destination address of the data
00979  * - *masterAddress: slave reads: destination address of the data; the special value
00980  *                                DEFAULT puts the data in the body of the reply msg
00981  *                                just after the RW_SLAVE_MEMORY_OUT structure
00982  *                   slave writes: source address of the data; the special value
00983  *                                DEFAULT gets the data from the body of the primitive
00984  *                                just after the RW_SLAVE_MEMORY_IN structure
00985  * - numWords: in input structure: number of 32 bit words to read or write */
00986 #define RW_SLAVE_MEMORY         (MASTER_PRIMITIVES_BASE)
00987 #define R_RW_SLAVE_MEMORY       100
00988     struct RW_SLAVE_MEMORY_IN {
00989         UINT32 slaveNumber;
00990         UINT32 readNotWrite;
00991         UINT32 *slaveAddress;   /* DEFAULT address defined above */
00992         UINT32 *masterAddress;  /* DEFAULT address defined above */
00993         UINT32 numWords;
00994     };
00995 
00996 /* Transmit serial data to controller FPGA */
00997 #define TRANS_SERIAL_DATA (1+(RW_SLAVE_MEMORY))
00998 #define R_TRANS_SERIAL_DATA 100
00999     struct TRANS_DATA {
01000         UINT32 port0Data; /* 32b serial data port 0 */
01001         UINT32 port1Data; /* 32b serial data port 1 */
01002     };
01003     struct TRANS_SERIAL_DATA_IN {
01004         UINT32   captureSerOn;      /* Capture module return data in input FIFOs */
01005         UINT32   streamLen[2], *streams;   /* data sets to transmit */
01006     };
01007 
01008 /* Set DSPINT to start slave. */
01009 #define START_SLAVE_EXECUTING     (1 + (TRANS_SERIAL_DATA))
01010 #define R_START_SLAVE_EXECUTING   104
01011     struct START_SLAVE_EXECUTING_IN {
01012         UINT32 slaveNumber;
01013         UINT32 commOnOff;
01014         UINT32 slaveType;
01015         UINT32 timeoutInUsec;
01016     };
01017     struct START_SLAVE_EXECUTING_OUT {
01018         UINT32 slaveNumber;
01019     };
01020     /* commOnOff options */
01021     #define SLV_DSP_COMM_OFF      0
01022     #define SLV_DSP_COMM_ON       1
01023     /* slaveType options */
01024     #define SLV_DSP_UNCONFIGURED  0
01025     #define SLAVE_CALIBRATE       1
01026     #define SLAVE_MONITOR         2
01027     #define SLAVE_ERROR_CHECK     3
01028     #define SLAVE_MEMORY_TEST     4
01029 
01030 /* Sets the parameters of the structure rodConfig.slvDspConfig[slvId]. */
01031 #define CONFIG_SLAVE            (1 + (START_SLAVE_EXECUTING))
01032 #define R_CONFIG_SLAVE          102
01033     struct CONFIG_SLAVE_IN {
01034         UINT32 slaveNumber;
01035         UINT32 commOnOff;
01036         UINT32 slaveType;
01037     };  /* parameters values are same as for START_SLAVE_EXECUTING */
01038 
01039 /*
01040  *  Reads or writes a field of a register in the master DSP memory map.
01041  * registerID: ID of the register being polled
01042  * offset: number of lsb in the field, starting with 0
01043  * width: width of the field
01044  *    mnemonic symbols for registerID, offset and width are in registerIndices.h
01045  * readNotWrite: 1 for read, 0 for write
01046  * dataIn: data to write for readNotWrite = 0; no significance for readNotWrite = 1
01047  * dataOut: data read for readNotWrite = 1; no significance for readNotWrite = 0
01048  */
01049 #define RW_REG_FIELD                 (1 + (CONFIG_SLAVE))
01050 #define R_RW_REG_FIELD               105
01051     struct RW_REG_FIELD_IN {
01052         UINT32 registerID;
01053         UINT32 offset;
01054         UINT32 width;
01055         UINT32 readNotWrite;
01056         UINT32 dataIn;
01057     };
01058     struct RW_REG_FIELD_OUT {
01059         UINT32 dataOut;
01060     };
01061 
01062 /*
01063  *  Polls a field of a register for a value.  A timeout is available.
01064  * registerID: ID of the register being polled
01065  * offset: number of lsb in the field, starting with 0
01066  * width: width of the field
01067  *    mnemonic symbols for registerID, offset and width are in registerIndices.h
01068  * desiredValue: value of the defined field to poll for
01069  * timeoutInUsec: timeout period in microseconds
01070  * found: indicates whether 'desiredValue' was found within 'timeoutInUsec'
01071  */
01072 #define POLL_REG_FIELD               (1 + (RW_REG_FIELD))
01073 #define R_POLL_REG_FIELD             105
01074     struct POLL_REG_FIELD_IN {
01075         UINT32 registerID;
01076         UINT32 offset;
01077         UINT32 width;
01078         UINT32 desiredValue;
01079         UINT32 timeoutInUsec;
01080     };
01081     struct POLL_REG_FIELD_OUT {
01082         UINT32 found;
01083     };
01084 
01085 /* Reads/writes some number of words from/to one of the FIFOs on the ROD.
01086  * - fifoID: INPUT_MEM, DEBUG_MEM or EVENT_MEM
01087  * - bank: BANK_A, BANK_B or (EVENT_MEM only) BANK_C
01088  * - readNotWrite: 1 for read, 0 for write
01089  * - numElements: number of fifo entries to read or write; NOTE: no packing, eg
01090  *              to write 20 elements to INPUT_MEM BANK_A requires 40 32b data words
01091  *              to write 20 elements to EVENT_MEM BANK_C requires 20 32b data words
01092  *              20 elements read from EVENT_MEM BANK_C will occupy 20 32b data words
01093  * - *dataBaseAdr: for readNotWrite = 0 source address of data for the FIFO
01094  *                                = 1 destination address for data from the FIFO
01095  *   if *dataBaseAdr = DEFAULT
01096  *     readNotWrite = 0: data is supplied with the RW_FIFO primitive after *data
01097  *     readNotWrite = 1: data is written to the reply message body after bytesXfrd
01098  *   There is also a scratch space in SDRAM at SCRATCH_BASE (memoryPartitions.h)
01099  * - bytesXfrd: Number of bytes read or written
01100  */
01101 #define RW_FIFO                   (1 + (POLL_REG_FIELD))
01102 #define R_RW_FIFO                 104
01103     struct RW_FIFO_IN {
01104         UINT32 fifoId;
01105         UINT32 bank;
01106         UINT32 readNotWrite;
01107         UINT32 numElements;
01108         UINT32 *dataBaseAdr;    /* DEFAULT value defined above */
01109     };
01110     struct RW_FIFO_OUT {
01111         UINT32 bytesXfrd;
01112     };
01113     #define INPUT_MEM 0x0             /* values of fifoID */
01114     #define DEBUG_MEM 0x1
01115     #define EVENT_MEM 0x2
01116     #define TIM_MEM   0x3
01117     #define BANK_A    0x0             /* values of bank; ignored for TIM_MEM */
01118     #define BANK_B    0x1
01119     #define BANK_C    0x2             /* EVENT_MEM only */
01120 
01121 /*
01122  *  Send a primitive list to a slave DSP.
01123  * slaveNumber: ID of slave DSP to recieve the list.
01124  * listLength: number of 32 bit words in the list.
01125  * *slavePrimList: Address of start of source data for the list.
01126  *   - *slavePrimList = DEFAULT indicates that the slave primitive list is stored in
01127  *     the body of this SEND_SLAVE_LIST primtive starting just after the last
01128  *     SEND_SLAVE_LIST_IN structure element.
01129  * *slaveRepData: Address where master should put slave reply data if the
01130  *             START_SLAVE_LIST primitive is executed with getSlaveReply != 0.
01131  *   - *slaveRepData = DEFAULT indicates that the slave reply list should be stored
01132  *     in the body of a reply message to the START_SLAVE_LIST primtive.
01133  */
01134 #define SEND_SLAVE_LIST      (1 + (RW_FIFO))
01135 #define R_SEND_SLAVE_LIST    103
01136     struct SEND_SLAVE_LIST_IN {
01137         UINT32 slaveNumber;
01138         UINT32 listLength;
01139         UINT32 *slavePrimList;    /* DEFAULT value defined above */
01140         UINT32 *slaveRepData;     /* DEFAULT value defined above */
01141     };
01142 
01143 /*
01144  *  Start a slave DSP executing its primitive list by setting its inListRdy bit.
01145  * slaveNumber: ID of slave DSP to execute list
01146  * pauseMasterList != 0 if master DSP list execution pauses while slave executes list
01147  * getSlaveReply != 0 if the master should read the slave reply data
01148  */
01149 #define START_SLAVE_LIST      (1 + (SEND_SLAVE_LIST))
01150 #define R_START_SLAVE_LIST    103
01151 struct START_SLAVE_LIST_IN {
01152     UINT32 slaveNumber;
01153     UINT32 pauseMasterList;
01154     UINT32 getSlaveReply;
01155 };
01156 
01157 /* pause, resume or abort a slave list */
01158 #define SLAVE_LIST_OP      (1 + (START_SLAVE_LIST))
01159 #define R_SLAVE_LIST_OP    101
01160     struct SLAVE_LIST_OP_IN {
01161         UINT32 slaveNumber;
01162         UINT32 listOp;
01163     };
01164     #define LIST_PAUSE  0
01165     #define LIST_RESUME 1
01166     #define LIST_ABORT  2
01167 
01168 /* Build & send a command stream to the detector electronics. sendData will ship
01169    a command stream back to the VME host. */
01170 #define BUILD_STREAM          (1 + (SLAVE_LIST_OP))
01171 #define R_BUILD_STREAM        102
01172     struct BUILD_STREAM_IN {
01173         struct  CmdList cmdList;
01174         UINT32  cmdBuff, reset, chip, fibre;
01175         UINT32  dataLen;    /* Length of the extra data, in bits. */
01176         UINT32  *data;      /* Start of the data for a command with large amounts of
01177                                data (masks & some pixel commands). */
01178     };
01179 
01180 #define SEND_STREAM          (1 + (BUILD_STREAM))
01181 #define R_SEND_STREAM        100
01182     struct SEND_STREAM_IN {
01183         UINT32 cmdBuff, captureSerOn;
01184     };
01185 
01186 /* configure a module, or send it's data (resident in memory) to control links.
01187    For input data, the pointer to configData is the start. */
01188 #define RW_MODULE_DATA     (1 + (SEND_STREAM))
01189 #define R_RW_MODULE_DATA   102
01190     struct RW_MODULE_DATA_IN {
01191         UINT32 readNotWrite, structId, moduleNum;
01192         Module *configData;
01193     };
01194     struct RW_MODULE_DATA_OUT {
01195         Module configData;
01196     };
01197     #define PHYSICS_MODULE_CONFIG  0
01198     #define SCAN_MODULE_CONFIG     1
01199     #define SPARE_MODULE_CONFIG    2
01200     #define N_MODULE_CONFIG_SETS ((SPARE_MODULE_CONFIG) -(PHYSICS_MODULE_CONFIG) +1)
01201 
01202 
01203 #define SEND_CONFIG      (1 + (RW_MODULE_DATA))
01204 #define R_SEND_CONFIG    105
01205     struct SEND_CONFIG_IN {
01206         UINT32   port,  captureSerOn, moduleNum[2], chipNum,
01207                  setLinks, restore, structId, groupId, dataType,
01208                  activeOnly, enableDataTaking;
01209     };
01210 
01211     #define NO_CONFIG_LOOP        0
01212     #define NORMAL_CONFIG_LOOP    1
01213     #define OFF_ROD_CONFIG_LOOP   2
01214 
01215     #if defined(SCT_ROD)
01216     #define CONFIG_MODULE_BASIC  0
01217     #define CONFIG_MODULE_TRIM   1
01218     #define CONFIG_MODULE_ALL    2
01219 
01220     #elif defined(PIXEL_ROD)
01221     //Pixel additive bitwise definitions; the 1st 14 correspond to the bit
01222     //definitions in the pixel control register.
01223     #define CONFIG_MODULE_ENABLE       0
01224     #define CONFIG_MODULE_SELECT       1
01225     #define CONFIG_MODULE_PREAMP       2
01226     #define CONFIG_MODULE_HITBUS       3
01227 
01228     #define CONFIG_MODULE_TDAC_0       4
01229     #define CONFIG_MODULE_TDAC_1       5
01230     #define CONFIG_MODULE_TDAC_2       6
01231     #define CONFIG_MODULE_TDAC_3       7
01232     #define CONFIG_MODULE_TDAC_4       8
01233 
01234     #define CONFIG_MODULE_FDAC_0       9
01235     #define CONFIG_MODULE_FDAC_1       10
01236     #define CONFIG_MODULE_FDAC_2       11
01237     #define CONFIG_MODULE_FDAC_3       12
01238     #define CONFIG_MODULE_FDAC_4       13
01239 
01240     #define CONFIG_MODULE_GLOBAL       16
01241     #define CONFIG_MODULE_CONTROL      17
01242     #define CONFIG_MODULE_TDAC         18
01243     #define CONFIG_MODULE_FDAC         19
01244 
01245     #define CONFIG_MODULE_SCAN_TDAC    20
01246     #define CONFIG_MODULE_SCAN_FDAC    21
01247     #define CONFIG_MODULE_MCC          22
01248     #define CONFIG_MODULE_ALL          23
01249     #endif
01250 
01251 
01252     #define ALL_MODULES 0xfe
01253     #define NO_MODULE   0xff
01254 
01255     #define MODULE_GROUP_0       0
01256     #define MODULE_GROUP_1       1
01257     #define MODULE_GROUP_2       2
01258     #define MODULE_GROUP_3       3
01259     #define MODULE_GROUP_4       4
01260     #define MODULE_GROUP_5       5
01261     #define MODULE_GROUP_6       6
01262     #define MODULE_GROUP_7       7
01263 
01264     #define MODULE_GROUP_ALL     8
01265     #define N_MODULE_GROUPS      (MODULE_GROUP_ALL)
01266 
01267 #define DSP_RESET      (1 + (SEND_CONFIG))
01268 #define R_DSP_RESET    100
01269     struct DSP_RESET_IN {
01270         UINT32  slvBits, forceSync, nAttempts, timeOut;
01271     };
01272 
01273 #define SET_ROD_MODE   (1 + (DSP_RESET))
01274 #define R_SET_ROD_MODE    101
01275     struct SET_ROD_MODE_IN {
01276         UINT32  mode, flag, fifoSetup, nBits, delay, evtsPerL1A, message;
01277     };
01278 
01279 #define RW_MODULE_VARIABLE  (1 + (SET_ROD_MODE))
01280 #define R_RW_MODULE_VARIABLE    102
01281     struct RW_MODULE_VARIABLE_IN {
01282         UINT32  read,  structId, groupId, module, chip, 
01283                 varType;
01284 
01285         UINT32  info;     /* for writing: output message? */
01286         UINT32 dataLen;   /* for writing: length of data (e.g. mask= 4) */
01287         MDAT32 *data;     /* for writing: *data is written to all selected chips/modules */
01288     };
01289     struct RW_MODULE_VARIABLE_OUT {
01290         UINT32  nModData, dataLen;
01291         MDAT32 *data;
01292     };
01293 
01294     #define MVAR_GROUP_ID    100
01295     #define MVAR_ACTIVE      101
01296     #define MVAR_SELECT      102
01297 
01298 
01299 #define RW_BOC_DATA  (1 + (RW_MODULE_VARIABLE))
01300 #define R_RW_BOC_DATA    100
01301     struct RW_BOC_DATA_IN {
01302         UINT32  read, sendToBoc, dataLen, *data;
01303     };
01304     struct RW_BOC_DATA_OUT {
01305         BOCConfig bocCfgData;
01306     };
01307 
01308 
01309 #define BOC_HISTOGRAM  (1 + (RW_BOC_DATA))
01310 #define R_BOC_HISTOGRAM    100
01311     struct BOC_HISTOGRAM_IN {
01312         UINT32  numSamples, numLoops;
01313     };
01314     struct BOC_HISTOGRAM_OUT {
01315         UINT32 histo[96][2];
01316     };
01317 
01318 #define LAST_MASTER_PRIMITIVE   (BOC_HISTOGRAM)
01319 #define NUM_MASTER_PRIMITIVES   ((LAST_MASTER_PRIMITIVE)-(MASTER_PRIMITIVES_BASE)+1)
01320 
01321 
01322 #if   defined(SCT_ROD)
01323     #define MASTER_SCT_PRIMITIVES_BASE 0x2800
01324 
01325     #ifdef COMMENTED
01326     #define XXX (MASTER_SCT_PRIMITIVES_BASE)
01327     #define LAST_MASTER_SCT_PRIMITIVE   (XXX)
01328     #define NUM_MASTER_SCT_PRIMITIVES   \
01329         ((LAST_MASTER_SCT_PRIMITIVE)-(MASTER_SCT_PRIMITIVES_BASE)+1)
01330     #endif
01331 
01332     #define NUM_MASTER_SCT_PRIMITIVES  0
01333 
01334 #elif defined(PIXEL_ROD)
01335     #define MASTER_PIXEL_PRIMITIVES_BASE 0x2800
01336 
01337     #define TEST_GLOBAL_REG (MASTER_PIXEL_PRIMITIVES_BASE)
01338     #define R_TEST_GLOBAL_REG   112
01339         struct TEST_GLOBAL_REG_IN {
01340             UINT32 structId;
01341             UINT32 moduleId;
01342             UINT32 FEIndex; 
01343         };
01344         struct TEST_GLOBAL_REG_OUT {
01345             UINT32 testResult;
01346             UINT32 dataLen;
01347             MDAT32 *data;
01348         };
01349 
01350     #define LAST_MASTER_PIXEL_PRIMITIVE   (TEST_GLOBAL_REG)
01351     #define NUM_MASTER_PIXEL_PRIMITIVES   \
01352         ((LAST_MASTER_PIXEL_PRIMITIVE)-(MASTER_PIXEL_PRIMITIVES_BASE)+1)
01353 #endif
01354 
01355 
01356 #if   defined(SCT_ROD)
01357     #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)     \
01358                             +(NUM_SLAVE_PRIMITIVES)      \
01359                             +(NUM_MASTER_PRIMITIVES)     \
01360                             +(NUM_COMMON_SCT_PRIMITIVES) \
01361                             +(NUM_SLAVE_SCT_PRIMITIVES)  \
01362                             +(NUM_MASTER_SCT_PRIMITIVES)   )
01363 
01364 #elif defined(PIXEL_ROD)
01365     #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)       \
01366                             +(NUM_SLAVE_PRIMITIVES)        \
01367                             +(NUM_MASTER_PRIMITIVES)       \
01368                             +(NUM_COMMON_PIXEL_PRIMITIVES) \
01369                             +(NUM_SLAVE_PIXEL_PRIMITIVES)  \
01370                             +(NUM_MASTER_PIXEL_PRIMITIVES)   )
01371 
01372 #else
01373     #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES) \
01374                             +(NUM_SLAVE_PRIMITIVES)  \
01375                             +(NUM_MASTER_PRIMITIVES)   )
01376 
01377 #endif
01378 
01379 /************************************************************************************
01380  *  Primitive function prototypes (not needed by the host processor).
01381  ************************************************************************************/
01382 #if (defined(I_AM_MASTER_DSP) || defined(I_AM_SLAVE_DSP))
01383 INT32 noPrimitive(struct PRIM_DATA *);
01384 
01385 INT32 echo(struct PRIM_DATA *);
01386 INT32 setErrMsgMask(struct PRIM_DATA *);
01387 INT32 pauseList(struct PRIM_DATA *);
01388 INT32 eventTrapSetup(struct PRIM_DATA *);
01389 INT32 setMemory(struct PRIM_DATA *);
01390 INT32 copyMemory(struct PRIM_DATA *);
01391 INT32 memoryTest(struct PRIM_DATA *);
01392 INT32 setLed(struct PRIM_DATA *);
01393 INT32 flashLed(struct PRIM_DATA *);
01394 INT32 sendData(struct PRIM_DATA *);
01395 INT32 moduleMask(struct PRIM_DATA *);
01396 INT32 setTrigger(struct PRIM_DATA *);
01397 INT32 startTask(struct PRIM_DATA *);
01398 INT32 taskOperation(struct PRIM_DATA *);
01399 INT32 test(struct PRIM_DATA *);
01400 INT32 writeBuffer(struct PRIM_DATA *);
01401 
01402 #if   defined(SCT_ROD)
01403 #elif defined(PIXEL_ROD)
01404 #endif
01405 
01406 INT32 startEventTrapping(struct PRIM_DATA *);
01407 INT32 stopEventTrapping(struct PRIM_DATA *);
01408 INT32 histogramSetup(struct PRIM_DATA *);
01409 
01410 #if   defined(SCT_ROD)
01411 #elif defined(PIXEL_ROD)
01412 #endif
01413 
01414 INT32 rwSlaveMemory(struct PRIM_DATA *);
01415 INT32 transSerialData (struct PRIM_DATA *);
01416 INT32 startSlaveExecuting(struct PRIM_DATA *);
01417 INT32 configSlave(struct PRIM_DATA *);
01418 INT32 rwRegField(struct PRIM_DATA *);
01419 INT32 pollRegField(struct PRIM_DATA *);
01420 INT32 rwFifo(struct PRIM_DATA *);
01421 INT32 sendSlaveList(struct PRIM_DATA *);
01422 INT32 startSlaveList(struct PRIM_DATA *);
01423 INT32 slaveListOp(struct PRIM_DATA *);
01424 INT32 buildStream(struct PRIM_DATA *);
01425 INT32 sendStream(struct PRIM_DATA *);
01426 INT32 rwModuleData(struct PRIM_DATA *);
01427 INT32 sendConfig(struct PRIM_DATA *);
01428 INT32 dspReset(struct PRIM_DATA *);
01429 INT32 setRodMode(struct PRIM_DATA *);
01430 INT32 rwModuleVariable(struct PRIM_DATA *);
01431 INT32 rwBocData(struct PRIM_DATA *);
01432 INT32 BOChistogram(struct PRIM_DATA *primData);
01433 /* INT32 configBoc(struct PRIM_DATA *); */
01434 
01435 #if   defined(SCT_ROD)
01436 #elif defined(PIXEL_ROD)
01437     INT32 testGlobalReg(struct PRIM_DATA *);  
01438 #endif
01439 
01440 #endif  /* primitive parameters definition block */
01441 
01442 #endif

Generated on Thu Jul 15 09:50:50 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5