Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | 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  *   primitiveBuilding.txt:  describes how to build primitives
00010  *   primParams_pxl.h, primParams_sct.h: detector-specific versions of this file.
00011  *   listManager.c: Routines which manage the execution of a primitive list and
00012  *                 writing the reply data.
00013  *   primFuncts.c: Contains primitive execution functions common to the master and the
00014  *                slaves and the function which initializes the primParameters array
00015  *                of structures.
00016  *   masterPrimFuncts.c/slavePrimFuncts.c: Contain primitive execution functions
00017  *                specific to the master/slave DSP.
00018  *   primFuncts.h: Declares the structure tag which communicates necessary information
00019  *                to primitive functions.
00020  *
00021  *  Damon Fasching, UW Madison                            fasching@wisconsin.cern.ch
00022  *  Douglas Ferguson, UW Madison   (510) 486-5230         dpferguson@lbl.gov
00023  *
00024  *  modifications/bugs
00025  *   - Split the primitive IDs into 3 sets, so that future primitives can
00026  *     be placed in the appropriate section (common/slave/master) without
00027  *     affecting the already existing primitive lists on the host machines.
00028  *     Currently primitives must be added to the end of the entire list to
00029  *     avoid ID changes of existing primitives & thus re-writes of the
00030  *     primitive lists. Updated the example.                         10.04.02 dpsf
00031  *   - Moved rodConfiguration #defines to rodConfiguration.h, where
00032  *     they belong.                                                  11.04.02 dpsf
00033  *
00034  *   - Split off detector-specific primitives into their own files.  
00035  ************************************************************************************/
00036 #ifndef PRIM_PARAMS
00037 #define PRIM_PARAMS
00038 
00039 #include "processor.h"
00040 #include "serialStreams.h"
00041 #include "scanControl.h"
00042 #include "bocStructure.h"
00043 #include "rodConfiguration.h"
00044 #include "router.h"
00045 //#include "primList.h"
00046 
00047 #if   defined(SCT_ROD)
00048     #include "primParams_sct.h"
00049 #elif defined(PIXEL_ROD)
00050     #include "primParams_pxl.h"
00051 #endif
00052 
00053 #define PRIM_LIST_REVISION     112
00054 
00055 /* default value for primitive parameters, function arguments, etc */
00056 #define DEFAULT (0xFFFFFFFF)
00057 
00058 /************************************************************************************
00059  *                        Primitives common to all DSPs go here
00060  * Note: some of these primitives (eventTrapSetup, triggerMask, setTrigger) are used
00061  * to coordinate the DSPs with each other or other electronics on the ROD (such as
00062  * the router). These primitives should be sent to the master DSP from the host; the
00063  * master DSP primitive will then set the appropriate board registers, etc. and pass
00064  * on the primitive to the slave DSP. The primitive passing software will not break
00065  * if the host sends one of these primitives directly to a slave, but slave
00066  * applications might break as a result of inconsistent parameter settings.
00067  ************************************************************************************/
00068 #define COMMON_PRIMITIVES_BASE 0x0
00069 
00070 enum {
00071     ECHO= COMMON_PRIMITIVES_BASE,
00072     SET_MESSAGE_MASK,
00073     PAUSE_LIST,
00074     EVENT_TRAP_SETUP,
00075     SET_MEMORY,
00076     COPY_MEMORY,
00077     MEMORY_TEST,
00078     SET_LED,
00079     FLASH_LED,
00080     SEND_DATA,
00081     MODULE_MASK,
00082     SET_TRIGGER,
00083     START_TASK,
00084     TASK_OPERATION,
00085 
00086 #ifndef NEWDEF
00087     TEST,
00088 
00089 #else
00090     ZEN_PRIM,
00091 
00092 #endif
00093 
00094     WRITE_BUFFER,
00095     //SET_BIN,
00096     LAST_COMMON_PRIMITIVE
00097 };
00098 
00099 #define NUM_COMMON_PRIMITIVES   ((LAST_COMMON_PRIMITIVE)-(COMMON_PRIMITIVES_BASE))
00100 
00101 /* Echo the primitive message body back in the reply message body. Echo's input
00102    and output data is unstructured. */
00103 #define R_ECHO                  100
00104 
00105 /* Set message level mask - levels which are masked will not write a message
00106    to the text buffer. */
00107 #define R_SET_MESSAGE_MASK          100
00108     struct SET_ERRMSG_MASK_IN {
00109         UINT32 messageMask;
00110     };
00111 
00112 /* Pause the execution of the primitive list.  List execution will resume when the
00113    RESUME bit is set in the command register. */
00114 #define R_PAUSE_LIST            100
00115 
00116 /* eventTrapSetup:
00117    Sets the event trapping parameters for a particular slave.  They need to be set
00118    in the slave DSP and in the router FPGA. The primitive is common to MDSP & SDSPs-
00119    however eventTrapSetup is intended to be a HOST to MASTER DSP primitive only; the
00120    MDSP then sets up the router registers and passes a primitive list to call
00121    eventTrapSetup on the SDSP(s).  Trap configuation is not independent, if only
00122    one trap is used, it must be trap 0. The primary purpose for trap 1 is to have
00123    a way of running short immediate tasks with a different function (like trapping
00124    events) on the DSP, while it continues a task such as occupancy counting.
00125  */
00126 #define R_EVENT_TRAP_SETUP      103
00127     struct EVENT_TRAP_SETUP_IN {
00128         UINT32 slvBits, numberOfEvents, timeoutInUsec;
00129         UINT32 extRouterSetup, distribute;
00130         UINT32 releaseFrames, permitBackPressure, dataMode, sLink,
00131                format, trapStray,  iterLimit;
00132         UINT32 trapConfig[2], trapExclusionFlag[2], trapFunction[2],
00133                trapMatch[2],  trapModulus[2],       trapRemainder[2];
00134     };
00135 
00136     struct EVENT_TRAP_SETUP_OUT {
00137         UINT32 errorCode;
00138     };
00139 
00140     #define  COLLECT_FOREVER  0
00141     #define  KEEP_EVENTS      0
00142 
00143     #define  TRAP_DISTRIB_PRIMARY    0
00144     #define  TRAP_DISTRIB_SECONDARY  1
00145     #define  TRAP_DISTRIB_BOTH       2
00146     #define  TRAP_DISTRIB_NEITHER    3
00147 
00148     #define  TRAP_FMT_NORMAL  0
00149     #define  TRAP_FMT_ERROR   1
00150 
00151 /* Quickly set a section of the DSP's memory */
00152 #define R_SET_MEMORY         100
00153     struct SET_MEMORY_IN {
00154         UINT32 *start, size, val;
00155     };
00156 
00157 /* Quickly copy one section of the DSP's memory into another section */
00158 #define R_COPY_MEMORY        100
00159     struct COPY_MEMORY_IN {
00160         UINT32 *source, *destination, size;
00161     };
00162 
00163 /* New memory test, designed to work with full code (ie not the memory-test mode) */
00164 #define R_MEMORY_TEST        102
00165     struct MEMORY_TEST_IN {
00166         UINT32 *start, size, repetitions[6], errorsBeforeFail, continueOnError;
00167         UINT32 nReads, dmaFlag;
00168     };
00169 
00170     struct MEMORY_TEST_OUT {
00171         UINT32 returnCode;
00172     };
00173 
00174 /* Turn an LED on or off. */
00175 #define R_SET_LED            104
00176     struct SET_LED_IN {
00177         UINT32  ledNum, ledState;
00178     };
00179 
00180     #define YELLOW_LED 0
00181     #define GREEN_LED  1
00182     #define RED_LED    2
00183 
00184     #define OFF     0
00185     #define ON      1
00186     #define TOGGLE  2
00187 
00188 /* Flash an LED.  Period and number of flashes are settable parameters. */
00189 #define R_FLASH_LED          103
00190     struct FLASH_LED_IN {
00191         UINT32 ledNum, period, numTimes;
00192     };
00193 
00194 /* Retrieve data, or a pointer to it, from the DSP */
00195 #define R_SEND_DATA          103
00196     struct SEND_DATA_IN {
00197         UINT32 dataType, auxVal, repBufferFlag, timeout;
00198     };
00199     struct SEND_DATA_OUT {
00200         void   *dataPtr;
00201         UINT32 dataLength;
00202     };
00203 
00204     #define REPLY_POINTER      0
00205     #define REPLY_DIRECT_DATA  1
00206 
00207     #define MAP_DATA       0x00
00208     #define PRIMITIVE_DATA 0x01
00209 
00210     #define MIRROR_DATA    0x10
00211     #define ROUTER_DATA    0x11
00212     #define STREAM_DATA    0x12
00213 
00214     #define EVENT_DATA     0x20
00215     #define HISTOGRAM_DATA 0x21
00216     #define OCCUPANCY_DATA 0x22
00217     #define FIT_DATA       0x23
00218     #define BIN_DATA       0x24
00219     #define ERROR_DATA     0x25
00220 
00221 /* moduleMask defines the link setup (command & data) for the modules. Like
00222    eventTrapSetup, moduleMask is meant to be sent from the host to the master DSP,
00223    which will transfer its data to the slave DSP(s) if desired. */
00224     #define R_MODULE_MASK       101
00225 
00226     #if defined(I_AM_SLAVE_DSP)
00227         struct MODULE_MASK_IN {
00228             ModuleMaskData moduleMaskData[N_TOTMODULES];
00229         };
00230     #else
00231         struct MODULE_MASK_IN {
00232             UINT32 moduleNum, port, useStructSet, passOn, slvBits;
00233             UINT32 cmdLine, dataLine[4];
00234             UINT32 cfg, modMask[2], maskType, storage, maskSet; 
00235         };
00236     #endif
00237 
00238 /* Send a trigger to the detector electronics. If setTrigger is issued to a
00239    slave DSP, the trigger source is assumed as external (possibly not even issued
00240    by the master DSP); in this case only the current bin & histogram set are set. */
00241 #define R_SET_TRIGGER        102
00242     struct SET_TRIGGER_IN {
00243         struct  CmdList cmdList[2];
00244         UINT32  slvBits;
00245         UINT16  cmdBuff, preBuilt;
00246         UINT32  chipAddress, bin, set;
00247         UINT32  repetitions, interval;
00248         UINT32  preBuiltDataOffset[2];
00249         UINT16  incCmd[2];
00250         UINT32  incData[2];
00251     };
00252 
00253 /* Serial port definitions; used by several primitives & tasks: */
00254 #define SP0      0
00255 #define SP1      1
00256 #define SP_BOTH  2
00257 
00258 #define R_START_TASK         101
00259     /* Task revision numbers must be updated whenever a task's input parameters
00260        are modified. Revision numbers of the tasks should not exceed 0xff. If
00261        a task has a default position for its memory base (eg. trapTask), that is
00262        defined inside memoryPartitions.h along with the other memory-related
00263        constants. */
00264 
00265     /* master */
00266 /* Task which controls an entire histogram scan */
00267     #define R_HISTOGRAM_CTRL_TASK   107
00268 
00269     #if defined(SCT_ROD)
00270 
00271     struct XPair {
00272         FLOAT32 x0, delta_x;
00273     };
00274     struct RangeList {
00275         struct XPair xPair[5]; 
00276     };
00277 
00278     struct  HISTOGRAM_CTRL_TASK_IN {
00279         UINT8   slvBits, port, configRegister[2];
00280 
00281         UINT8   configSctSet, dataSet;
00282         UINT8   groupRangeMap[2];
00283 
00284         UINT8   groupDSPMap[4];
00285 
00286         UINT8   groupSPMap[2];
00287         UINT8   globalCtrl, syncLevel;
00288 
00289         UINT32  *histoBase;
00290 
00291         UINT8   doChipOcc, dataFormat, binSize, unused1;
00292         UINT8   extSetup, dataPath, capture, useRangeList /* unused2 */;
00293 
00294         UINT32  repetitions, nBins, bin0;
00295 
00296         struct  RangeList rangeList[2];
00297         FLOAT32 *dataPtr[2];
00298 
00299         struct  CmdList triggerSequence[2];
00300         UINT8   incCmd[2];
00301         UINT8   calLineLoop;
00302         UINT8   distributionToggle;
00303 
00304         UINT32  incData[2];
00305 
00306         UINT32  genData[10];
00307     };
00308 
00309     struct  HISTO_CTRL_TASK_IN {
00310         ScanControl scanControl;
00311     };
00312 
00313     #elif defined(PIXEL_ROD)
00314         struct  HISTOGRAM_CTRL_TASK_IN {
00315             ScanControl scanControl;
00316         };
00317 
00318     #endif
00319 
00320     #define MODULE_BASIC  0
00321     #define MODULE_TRIM   1
00322     #define MODULE_ALL    2
00323 
00324     #define EXT_SETUP_NONE    0
00325     #define EXT_SETUP_RCF     1 
00326     #define EXT_SETUP_ROUTER  2
00327     #define EXT_SETUP_SET     4
00328     #define EXT_SETUP_HISTO   8 
00329     #define EXT_SETUP_HTASK   16 
00330 
00331     #define DATA_PATH_NORMAL  0
00332     #define DATA_PATH_INMEM   1
00333 
00334     #define MODULE_GROUP   0
00335     #define ROUTER_DISTRIB 1
00336 
00337     #define SYNC_NEWBIN    0
00338     #define SYNC_TOTAL     1
00339 
00340     struct HISTOGRAM_CTRL_TASK_OUT {
00341         UINT32  totalTime;
00342         UINT32  slvProcTime[4];
00343         UINT32  *dataPtr, dataLength;
00344     };
00345 
00346     #define R_MIRROR_TASK     101
00347     struct MIRROR_TASK_IN {
00348         UINT32 slvBits, mirrorFreq, *mirrorBase,
00349                *mirrorSlvBase, mirrorLen;
00350     };
00351 
00352     #define MIRROR_DEFAULT_BASE 0x80008000
00353 
00354     #define R_TRAP_REQ_TASK   101
00355     struct TRAP_REQ_TASK_IN {
00356         UINT32 slvBits, watchFreq;
00357     };
00358 
00359     /* slave */
00360     #define R_HISTOGRAM_TASK  100
00361     struct HISTOGRAM_TASK_IN {
00362         UINT32 nEvents, controlFlag;  /* nEvents can equal COLLECT_FOREVER too. */
00363     };
00364 
00365     /* control flag settings: */
00366     #define MASTER_HREG     0
00367     #define LOCAL_INC       1
00368     #define LOCAL_SET_TRIG  2
00369 
00370     struct HISTOGRAM_TASK_OUT {
00371         UINT32  nEvents, binsDone;
00372         FLOAT32 avgProcTime;
00373         UINT32  *dataPtr, dataLength;
00374     };
00375 
00376     #define R_TRAP_TASK       100
00377     struct TRAP_TASK_IN {
00378         UINT32 nEvents, reloadInterval, trapType, eventType,
00379                *trapBufferBase, trapBufferLength;
00380     };
00381 
00382     struct TRAP_TASK_OUT {
00383         UINT32  nEvents, dataLen;
00384         UINT32  *bufferBase, bufferLen;
00385     };
00386 
00387     #define R_OCCUPANCY_TASK  100
00388     struct OCCUPANCY_TASK_IN {
00389         UINT32 nEvents, nFilters, splitFlag;
00390         char   filter[16];
00391     };
00392 
00393     #define R_ERROR_TASK      101
00394     struct ERROR_TASK_IN {
00395         UINT32 errorType;
00396     };
00397     
00398     /*  //Left overs from dicks errorTask
00399     #define N_EFB_ERROR_BITS 16
00400     enum {
00401         ERRORTYPE_HEADER=0, //
00402         ERRORTYPE_TRAILER, //
00403         ERRORTYPE_FEFLAG,
00404         ERRORTYPE_SYNCHBIT,//
00405         ERRORTYPE_MCCFLAG,
00406         ERRORTYPE_L1ID, //
00407         ERRORTYPE_BCID, //
00408         ERRORTYPE_TIMEOUT, //
00409         ERRORTYPE_ALMOSTFULL, //
00410         ERRORTYPE_OVERFLOW, //
00411         ERRORTYPE_NONSEQCHIP,
00412         ERRORTYPE_INVROW,
00413         ERRORTYPE_INVCOL,
00414         ERRORTYPE_MCCSKIP,
00415         ERRORTYPE_SPARE1,
00416         ERRORTYPE_SPARE2,
00417         ERRORTYPE_DATALOSS,
00418         ERRORTYPE_LAST
00419     };
00420 
00421     enum {
00422         ERRORTYPE_D_=0,
00423         ERRORTYPE_D_TIMEOUTDATA, //
00424         ERRORTYPE_D_MISSINGTRAILER,
00425         ERRORTYPE_D_BCID, //
00426         ERRORTYPE_D_OVERFLOW,
00427         ERRORTYPE_D_INVROWCOL,
00428         ERRORTYPE_D_RAWDATA,
00429         ERRORTYPE_D_FE_ERROR,
00430         ERRORTYPE_D_LAST
00431     };
00432     */
00433 
00434     #define MAX_LINKS 96
00435 
00436     enum {
00437         SCT_FEERROR=0,
00438         SCT_PREAMBLE,
00439         SCT_TIMEOUT,
00440         SCT_L1ERROR,
00441         SCT_BCERROR,
00442         SCT_TRAILER,
00443         SCT_HTLIMIT,
00444         SCT_OVERFLOW,
00445         SCT_HITERROR1,
00446         SCT_HITERROR2,
00447         MAX_ERRORS
00448     };
00449 
00450     struct LINK_INFO {
00451         UINT32 nErrEvents;  // number of events with errors
00452         UINT32 nErrors;     // number of errors in total
00453 
00454         UINT32 theChip;
00455         UINT32 theChannel;
00456         UINT32 theError;
00457 
00458         UINT16 errCount[MAX_ERRORS]; // number of errors of specific types
00459 
00460         UINT8  module;
00461         UINT8  stream;
00462 
00463         UINT8  unused[2];
00464     };
00465 
00466     struct ERROR_INFO {
00467         UINT32 nErrEvents;  // number of events with errors
00468         UINT32 nErrors;     // number of errors in total
00469 
00470         struct LINK_INFO linkInfo[MAX_LINKS +1];
00471     };
00472 
00473     struct ERROR_TASK_OUT { // retrieve ERROR_INFO sturct using SEND_DATA primitive
00474         UINT32 nErrEvents;  // number of events with errors
00475         UINT32 nErrors;     // number of errors in total
00476     };
00477 
00478     #define R_RESYNCH_TASK    100
00479     struct RESYNCH_TASK_IN {
00480         UINT32 errorType;
00481     };
00482 
00483     /* tasks can have their own specialized output structures, this is a
00484        general one. It is stored as an array of external structures in
00485        the task manager, so that if a task completes & later the data is
00486        requested, it can be supplied. */
00487     struct GEN_TASK_OUT {
00488         void   *dataPtr;
00489         UINT32 dataLength;
00490     };
00491 
00492     union TASK_STRUCTURES_OUT {
00493         struct HISTOGRAM_CTRL_TASK_OUT  histoCtrlTaskOut;
00494         struct HISTOGRAM_TASK_OUT       histogramTaskOut;
00495         struct TRAP_TASK_OUT            trapTaskOut;
00496         struct ERROR_TASK_OUT           errorTaskOut;
00497         struct GEN_TASK_OUT             genTaskOut;
00498     };
00499 
00500     /* MAX_NUM_TASKS is the maximum of the two task numbers for master &
00501        slave DSPs. Bad Things can happen if it is not kept up to date */
00502     #define MAX_NUM_TASKS   5
00503 
00504     /* The IDs of the two task sets cannot not exceed 0xff, and must increment by 1. */
00505     /* master DSP tasks: */
00506     #define MASTER_TASK_BASE (0x10)
00507     #define SLAVE_TASK_BASE  (0x20)
00508 
00509     enum {
00510         HISTOGRAM_CTRL_TASK= MASTER_TASK_BASE,
00511         MIRROR_TASK,
00512         TRAP_REQ_TASK,
00513         
00514         HISTOGRAM_TASK= SLAVE_TASK_BASE,
00515         TRAP_TASK,
00516         OCCUPANCY_TASK,
00517         ERROR_TASK,
00518         RESYNCH_TASK
00519     };
00520 
00521 
00522     #define ALL_SLAVESX      5
00523 
00524     #define LAST_MASTER_TASK  (TRAP_REQ_TASK)
00525     #define NUM_MASTER_TASKS  ((LAST_MASTER_TASK)-(MASTER_TASK_BASE)+1)
00526 
00527     #define LAST_SLAVE_TASK  (RESYNCH_TASK)
00528     #define NUM_SLAVE_TASKS  ((LAST_SLAVE_TASK)-(SLAVE_TASK_BASE)+1)
00529 
00530     #if   defined(I_AM_MASTER_DSP)
00531         #define LAST_TASK  (LAST_MASTER_TASK)
00532         #define NUM_TASKS  (NUM_MASTER_TASKS)
00533         #define TASK_BASE  (MASTER_TASK_BASE)
00534     #elif defined(I_AM_SLAVE_DSP)
00535         #define LAST_TASK  (LAST_SLAVE_TASK)
00536         #define NUM_TASKS  (NUM_SLAVE_TASKS)
00537         #define TASK_BASE  (SLAVE_TASK_BASE)
00538     #endif
00539 
00540     union TASK_STRUCTURES_IN {
00541         struct HISTOGRAM_CTRL_TASK_IN  histoCtrlTaskIn;
00542         struct HISTO_CTRL_TASK_IN      scanCtrlIn;  //dpsf: temp- allow new or old struct.
00543         struct MIRROR_TASK_IN          mirrorMemoryTaskIn;
00544         struct TRAP_REQ_TASK_IN        trapRequestTaskIn;
00545 
00546         struct HISTOGRAM_TASK_IN  histogramTaskIn;
00547         struct TRAP_TASK_IN       trapTaskIn;
00548         struct OCCUPANCY_TASK_IN  occupancyTaskIn;
00549         struct ERROR_TASK_IN      errorTaskIn;
00550         struct RESYNCH_TASK_IN    resynchTaskIn;
00551     };
00552 
00553     struct START_TASK_IN {
00554         UINT32 taskType, taskRevision, priority, completionFlag;
00555         union  TASK_STRUCTURES_IN  taskStruct;
00556     };
00557 
00558 /* Perform operations such as stop, pause etc. on a running task: */
00559 #define R_TASK_OPERATION         100
00560     struct TASK_OPERATION_IN {
00561         UINT32 taskType, taskOperation, data;
00562     };
00563 
00564 #define TASK_STOP         0
00565 #define TASK_PAUSE        1
00566 #define TASK_RESUME       2
00567 #define TASK_QUERY        3
00568 #define TASK_RESET        4
00569 #define TASK_SETPRIORITY  5
00570 
00571 #define R_WRITE_BUFFER         101
00572     struct WRITE_BUFFER_IN {
00573         UINT32 buffer;
00574         char string[2396];
00575     };
00576 
00577     #define WRITE_BUFFER_ERR  0
00578     #define WRITE_BUFFER_INFO 1
00579     #define WRITE_BUFFER_DIAG 2
00580     #define WRITE_BUFFER_XFER 3
00581 
00582 #define R_SET_BIN   100
00583     typedef struct {
00584         #if defined(I_AM_MASTER_DSP)
00585             UINT32 slvBits;
00586         #endif
00587 
00588         UINT32 bin;
00589     } SetBinIn;
00590 
00591 /************************************************************************************
00592  *                             Slave DSP primitives go here.
00593  ************************************************************************************/
00594 #define SLAVE_PRIMITIVES_BASE  0x1000
00595 
00596 #ifndef NEWDEF
00597     enum {
00598         START_EVENT_TRAPPING= SLAVE_PRIMITIVES_BASE,
00599         STOP_EVENT_TRAPPING,
00600         HISTOGRAM_SETUP,
00601         //FIT_HISTOGRAMS
00602         LAST_SLAVE_PRIMITIVE
00603     };
00604 
00605 #else
00606     enum {
00607         START_EVENT_TRAPPING= SLAVE_PRIMITIVES_BASE,
00608         STOP_EVENT_TRAPPING,
00609         LAST_SLAVE_PRIMITIVE
00610     };
00611     
00612 #endif
00613 
00614 #define NUM_SLAVE_PRIMITIVES   ((LAST_SLAVE_PRIMITIVE)-(SLAVE_PRIMITIVES_BASE))
00615 
00616 #define R_START_EVENT_TRAPPING       101
00617 
00618 #define R_STOP_EVENT_TRAPPING        100
00619 
00620 /************************************************************************************
00621  *                          Master DSP primitives go here.
00622  ************************************************************************************/
00623 #define MASTER_PRIMITIVES_BASE 0x2000
00624 
00625 enum {
00626     RW_SLAVE_MEMORY= MASTER_PRIMITIVES_BASE,
00627     TRANS_SERIAL_DATA,
00628     START_SLAVE_EXECUTING,
00629     CONFIG_SLAVE,
00630     RW_REG_FIELD,
00631     POLL_REG_FIELD,
00632     RW_FIFO,
00633     SEND_SLAVE_LIST,
00634     START_SLAVE_LIST,
00635     SLAVE_LIST_OP,
00636     BUILD_STREAM,
00637     SEND_STREAM,
00638 
00639 #ifndef NEWDEF
00640     RW_MODULE_DATA,
00641     SEND_CONFIG,
00642 #endif
00643 
00644     DSP_RESET,
00645     SET_ROD_MODE,
00646 
00647 #ifndef NEWDEF
00648     RW_MODULE_VARIABLE,
00649 #endif
00650 
00651     RW_BOC_DATA,
00652     BOC_HISTOGRAM,
00653     WRITE_FLASH,
00654     LAST_MASTER_PRIMITIVE
00655 };
00656 
00657 #define NUM_MASTER_PRIMITIVES   ((LAST_MASTER_PRIMITIVE)-(MASTER_PRIMITIVES_BASE))
00658 
00659 /* Read or write a block of SDSP memory. The structure is the same for input & output */
00660 #define R_RW_SLAVE_MEMORY       100
00661     struct RW_SLAVE_MEMORY_IN {
00662         UINT32 slaveNumber;
00663         UINT32 readNotWrite;
00664         UINT32 *slaveAddress;   /* DEFAULT address defined above */
00665         UINT32 *masterAddress;  /* DEFAULT address defined above */
00666         UINT32 numWords;
00667     };
00668 
00669 /* Transmit serial data to controller FPGA */
00670 #define R_TRANS_SERIAL_DATA 100
00671     struct TRANS_DATA {
00672         UINT32 port0Data; /* 32b serial data port 0 */
00673         UINT32 port1Data; /* 32b serial data port 1 */
00674     };
00675     struct TRANS_SERIAL_DATA_IN {
00676         UINT32   captureSerOn;      /* Capture module return data in input FIFOs */
00677         UINT32   streamLen[2], *streams;   /* data sets to transmit */
00678     };
00679 
00680 /* Set DSPINT to start SDSP. */
00681 #define R_START_SLAVE_EXECUTING   104
00682     struct START_SLAVE_EXECUTING_IN {
00683         UINT32 slaveNumber;
00684         UINT32 commOnOff;
00685         UINT32 slaveType;
00686         UINT32 timeoutInUsec;
00687     };
00688     struct START_SLAVE_EXECUTING_OUT {
00689         UINT32 slaveNumber;
00690     };
00691 
00692     /* commOnOff options */
00693     #define SLV_DSP_COMM_OFF      0
00694     #define SLV_DSP_COMM_ON       1
00695 
00696     /* slaveType options */
00697     #define SLV_DSP_UNCONFIGURED  0
00698     #define SLAVE_CALIBRATE       1
00699     #define SLAVE_MONITOR         2
00700     #define SLAVE_ERROR_CHECK     3
00701     #define SLAVE_MEMORY_TEST     4
00702 
00703 /* Sets the parameters of the structure rodConfig.slvDspConfig[slvId]. */
00704 #define R_CONFIG_SLAVE          102
00705     struct CONFIG_SLAVE_IN {
00706         UINT32 slaveNumber;
00707         UINT32 commOnOff;
00708         UINT32 slaveType;
00709     };  /* parameters values are same as for START_SLAVE_EXECUTING */
00710 
00711 /* Reads or writes a field of a register in the master DSP memory map.
00712    registerID: ID of the register being polled
00713    offset: number of lsb in the field, starting with 0
00714    width: width of the field mnemonic symbols for registerID, offset and width
00715           are in registerIndices.h
00716    fRead: TRUE for read, FALSE for write
00717    dataIn: data to write for fRead= FALSE; no significance for fRead= TRUE
00718    dataOut: data read for fRead= TRUE; no significance for fRead= FALSE  */
00719 #define R_RW_REG_FIELD               105
00720     struct RW_REG_FIELD_IN {
00721         UINT32 registerID;
00722         UINT32 offset;
00723         UINT32 width;
00724         UINT32 readNotWrite;
00725         UINT32 dataIn;
00726     };
00727     struct RW_REG_FIELD_OUT {
00728         UINT32 dataOut;
00729     };
00730 
00731 /* Polls a field of a register for a value.  A timeout is available.
00732    registerID: ID of the register being polled
00733    offset: number of lsb in the field, starting with 0
00734    width: width of the field mnemonic symbols for registerID, offset and width
00735           are in registerIndices.h
00736    desiredValue: value of the defined field to poll for.
00737    timeoutInUsec: timeout period in microseconds.
00738    found: indicates whether 'desiredValue' was found within the timed period. */
00739 #define R_POLL_REG_FIELD             105
00740     struct POLL_REG_FIELD_IN {
00741         UINT32 registerID;
00742         UINT32 offset;
00743         UINT32 width;
00744         UINT32 desiredValue;
00745         UINT32 timeoutInUsec;
00746     };
00747     struct POLL_REG_FIELD_OUT {
00748         UINT32 found;
00749     };
00750 
00751 /* Reads/writes some number of words from/to one of the FIFOs on the ROD.
00752   - fifoID: INPUT_MEM, DEBUG_MEM or EVENT_MEM
00753   - bank: BANK_A, BANK_B or (EVENT_MEM only) BANK_C
00754   - fRead: TRUE for read, FALSE for write
00755   - numElements: number of fifo entries to read or write; NOTE: no packing, eg
00756                to write 20 elements to INPUT_MEM BANK_A requires 40 32b data words
00757                to write 20 elements to EVENT_MEM BANK_C requires 20 32b data words
00758                20 elements read from EVENT_MEM BANK_C will occupy 20 32b data words
00759   - *dataBaseAdr: source/destination  address of data for/from the FIFO
00760     if *dataBaseAdr = DEFAULT
00761       fRead = FALSE: data is supplied with the RW_FIFO primitive after *data
00762       fRead = TRUE: data is written to the reply message body after bytesXfrd
00763     There is also a scratch space in SDRAM at SCRATCH_BASE (memoryPartitions.h)
00764   - bytesXfrd: Number of bytes read or written */
00765 #define R_RW_FIFO                 104
00766     struct RW_FIFO_IN {
00767         UINT32 fifoId;
00768         UINT32 bank;
00769         UINT32 readNotWrite;
00770         UINT32 numElements;
00771         UINT32 *dataBaseAdr;    /* DEFAULT value defined above */
00772     };
00773     struct RW_FIFO_OUT {
00774         UINT32 bytesXfrd;
00775     };
00776 
00777     #define INPUT_MEM 0x0             /* values of fifoID */
00778     #define DEBUG_MEM 0x1
00779     #define EVENT_MEM 0x2
00780     #define TIM_MEM   0x3
00781     #define BANK_A    0x0             /* values of bank; ignored for TIM_MEM */
00782     #define BANK_B    0x1
00783     #define BANK_C    0x2             /* EVENT_MEM only */
00784 
00785 /* Send a primitive list to a slave DSP.
00786    slaveNumber: ID of slave DSP to recieve the list.
00787    listLength: number of 32 bit words in the list.
00788    *slavePrimList: Address of start of source data for the list.
00789      - *slavePrimList = DEFAULT indicates that the slave primitive list is stored in
00790        the body of this SEND_SLAVE_LIST primtive starting just after the last
00791        SEND_SLAVE_LIST_IN structure element.
00792    *slaveRepData: Address where master should put slave reply data if the
00793                START_SLAVE_LIST primitive is executed with getSlaveReply != 0.
00794      - *slaveRepData = DEFAULT indicates that the slave reply list should be stored
00795        in the body of a reply message to the START_SLAVE_LIST primtive. */
00796 #define R_SEND_SLAVE_LIST    103
00797     struct SEND_SLAVE_LIST_IN {
00798         UINT32 slaveNumber;
00799         UINT32 listLength;
00800         UINT32 *slavePrimList;    /* DEFAULT value defined above */
00801         UINT32 *slaveRepData;     /* DEFAULT value defined above */
00802     };
00803 
00804 /* Start a slave DSP executing its primitive list by setting its inListRdy bit.
00805    slaveNumber: ID of slave DSP to execute list
00806    pauseMasterList= TRUE if master DSP list execution pauses while slave executes list
00807    getSlaveReply= TRUE if the master should read the slave reply data. */
00808 #define R_START_SLAVE_LIST    103
00809     struct START_SLAVE_LIST_IN {
00810         UINT32 slaveNumber;
00811         UINT32 pauseMasterList;
00812         UINT32 getSlaveReply;
00813     };
00814 
00815 /* pause, resume or abort a slave list */
00816 #define R_SLAVE_LIST_OP    101
00817     struct SLAVE_LIST_OP_IN {
00818         UINT32 slaveNumber;
00819         UINT32 listOp;
00820     };
00821 
00822     #define LIST_PAUSE  0
00823     #define LIST_RESUME 1
00824     #define LIST_ABORT  2
00825 
00826 /* Build & send a command stream to the detector electronics. sendData will ship
00827    a command stream back to the VME host. */
00828 #define R_BUILD_STREAM        102
00829     struct BUILD_STREAM_IN {
00830         struct  CmdList cmdList;
00831         UINT32  port, reset, chip, fibre;
00832         UINT32  dataLen;    /* Length of the extra data, in bits. */
00833         UINT32  *data;      /* Start of the data for a command with large amounts of
00834                                data (masks & some pixel commands). */
00835     };
00836 
00837 #define R_SEND_STREAM        100
00838     struct SEND_STREAM_IN {
00839         UINT32 port, captureSerOn;
00840     };
00841 
00842 #define R_DSP_RESET    100
00843     struct DSP_RESET_IN {
00844         UINT32  slvBits, forceSync, nAttempts, timeOut;
00845     };
00846 
00847 #define R_SET_ROD_MODE    101
00848     struct SET_ROD_MODE_IN {
00849         UINT32  mode, flag, fifoSetup, nBits, delay, evtsPerL1A, message;
00850     };
00851 
00852 #define R_RW_BOC_DATA    100
00853     struct RW_BOC_DATA_IN {
00854         UINT32  read, sendToBoc, dataLen, *data;
00855     };
00856     struct RW_BOC_DATA_OUT {
00857         BOCConfig bocCfgData;
00858     };
00859 
00860 #define R_BOC_HISTOGRAM    100
00861     struct BOC_HISTOGRAM_IN {
00862         UINT32  numSamples, numLoops;
00863     };
00864     struct BOC_HISTOGRAM_OUT {
00865         UINT32 histo[96][2];
00866     };
00867 
00868 #define R_WRITE_FLASH    100
00869     typedef struct {
00870         void *buffPtr;
00871         UINT32 offset, length; /* effective address = &flash[offset] */
00872     } WriteFlashIn;
00873 
00874 #if defined(I_AM_HOST)
00875     #if   defined(SCT_ROD)
00876         #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)     \
00877                                 +(NUM_SLAVE_PRIMITIVES)      \
00878                                 +(NUM_MASTER_PRIMITIVES)     \
00879                                 +(NUM_COMMON_SCT_PRIMITIVES) \
00880                                 +(NUM_SLAVE_SCT_PRIMITIVES)  \
00881                                 +(NUM_MASTER_SCT_PRIMITIVES)   )
00882 
00883     #elif defined(PIXEL_ROD)
00884         #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)       \
00885                                 +(NUM_SLAVE_PRIMITIVES)        \
00886                                 +(NUM_MASTER_PRIMITIVES)       \
00887                                 +(NUM_COMMON_PIXEL_PRIMITIVES) \
00888                                 +(NUM_SLAVE_PIXEL_PRIMITIVES)  \
00889                                 +(NUM_MASTER_PIXEL_PRIMITIVES)   )
00890     #endif
00891 
00892 #elif defined(I_AM_MASTER_DSP)
00893     #if   defined(SCT_ROD)
00894         #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)     \
00895                                 +(NUM_MASTER_PRIMITIVES)     \
00896                                 +(NUM_COMMON_SCT_PRIMITIVES) \
00897                                 +(NUM_MASTER_SCT_PRIMITIVES)   )
00898 
00899     #elif defined(PIXEL_ROD)
00900         #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)       \
00901                                 +(NUM_MASTER_PRIMITIVES)       \
00902                                 +(NUM_COMMON_PIXEL_PRIMITIVES) \
00903                                 +(NUM_MASTER_PIXEL_PRIMITIVES)   )
00904     #endif
00905 
00906 #elif defined(I_AM_SLAVE_DSP)
00907     #if   defined(SCT_ROD)
00908         #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)     \
00909                                 +(NUM_SLAVE_PRIMITIVES)      \
00910                                 +(NUM_COMMON_SCT_PRIMITIVES) \
00911                                 +(NUM_SLAVE_SCT_PRIMITIVES)    )
00912 
00913     #elif defined(PIXEL_ROD)
00914         #define NUM_PRIMITIVES ( (NUM_COMMON_PRIMITIVES)       \
00915                                 +(NUM_SLAVE_PRIMITIVES)        \
00916                                 +(NUM_COMMON_PIXEL_PRIMITIVES) \
00917                                 +(NUM_SLAVE_PIXEL_PRIMITIVES)    )
00918     #endif
00919 
00920 #endif
00921 
00922 #include "convertParams.h"
00923 /************************************************************************************
00924  *  Primitive function prototypes (not needed by the host processor).
00925  ************************************************************************************/
00926 #if (defined(I_AM_MASTER_DSP) || defined(I_AM_SLAVE_DSP))
00927 INT32 noPrimitive(PrimData *);
00928 
00929 INT32 echo(PrimData *);
00930 INT32 setMessageMask(PrimData *);
00931 INT32 pauseList(PrimData *);
00932 INT32 eventTrapSetup(PrimData *);
00933 INT32 setMemory(PrimData *);
00934 INT32 copyMemory(PrimData *);
00935 INT32 memoryTest(PrimData *);
00936 INT32 setLed(PrimData *);
00937 INT32 flashLed(PrimData *);
00938 INT32 sendData(PrimData *);
00939 INT32 moduleMask(PrimData *);
00940 INT32 setTrigger(PrimData *);
00941 INT32 startTask(PrimData *);
00942 INT32 taskOperation(PrimData *);
00943 //INT32 setBin(PrimData *);
00944 INT32 writeBuffer(PrimData *);
00945 
00946 INT32 startEventTrapping(PrimData *);
00947 INT32 stopEventTrapping(PrimData *);
00948 
00949 INT32 rwSlaveMemory(PrimData *);
00950 INT32 transSerialData (PrimData *);
00951 INT32 startSlaveExecuting(PrimData *);
00952 INT32 configSlave(PrimData *);
00953 INT32 rwRegField(PrimData *);
00954 INT32 pollRegField(PrimData *);
00955 INT32 rwFifo(PrimData *);
00956 INT32 sendSlaveList(PrimData *);
00957 INT32 startSlaveList(PrimData *);
00958 INT32 slaveListOp(PrimData *);
00959 INT32 buildStream(PrimData *);
00960 INT32 sendStream(PrimData *);
00961 INT32 dspReset(PrimData *);
00962 INT32 setRodMode(PrimData *);
00963 INT32 rwBocData(PrimData *);
00964 INT32 bocHistogram(PrimData *);
00965 /* INT32 configBoc(PrimData *); */
00966 INT32 writeFlash(PrimData *);
00967 
00968 #endif  /* primitive parameters definition block */
00969 #endif  /* Multiple inclusion protection */

Generated on Thu Dec 22 20:17:07 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5