LLC2_API
|
00001 /***************************************************************************** 00002 * 00003 * File: llcontrol.h 00004 * 00005 * $RCSfile: llcontrol.h,v $ 00006 * 00007 * Copyright (C) 2001 D-TACQ Solutions Ltd 00008 * 00009 * Description: 00010 * application implementing the LOW LATENCY CONTROL feture 00011 * 00012 * $Id: llcontrol.h,v 1.1.4.17 2009/09/29 13:09:14 pgm Exp $ 00013 * $Log: llcontrol.h,v $ 00014 * Revision 1.1.4.17 2009/09/29 13:09:14 pgm 00015 * RFM emulation (not complete) 00016 * 00017 * Revision 1.1.4.16 2009/04/02 13:19:01 pgm 00018 * docs away 00019 * 00020 * Revision 1.1.4.15 2009/03/28 18:47:39 pgm 00021 * sync2VAO32 take 1 00022 * 00023 * Revision 1.1.4.14 2006/02/23 21:56:40 pgm 00024 * remove unwanted statics 00025 * 00026 * Revision 1.1.4.13 2006/01/15 11:18:18 pgm 00027 * SYNC_2V 00028 * 00029 * Revision 1.1.4.12 2006/01/09 13:40:31 pgm 00030 * SYNC_2V mode implemented 00031 * 00032 * Revision 1.1.4.11 2005/12/07 10:21:15 pgm 00033 * *** empty log message *** 00034 * 00035 * Revision 1.1.4.10 2005/12/06 21:22:40 pgm 00036 * ACQ216HS channels=2 pulls in antiphase 00037 * 00038 * Revision 1.1.4.9 2005/12/06 18:11:31 pgm 00039 * ACQ216HS (ChannelMask) option 00040 * 00041 * Revision 1.1.4.8 2005/11/04 17:26:18 pgm 00042 * *** empty log message *** 00043 * 00044 * Revision 1.1.4.7 2005/10/03 15:03:48 pgm 00045 * acq216 llc with prams 00046 * 00047 * Revision 1.1.4.6 2005/09/25 20:31:50 pgm 00048 * blocklen 00049 * 00050 * Revision 1.1.4.5 2005/08/11 10:02:24 pgm 00051 * SYNC_ECM - init host side slave memory areas 00052 * 00053 * Revision 1.1.4.4 2005/08/01 11:10:24 pgm 00054 * V2 part 1 running - local status, no hbpoll - ECM 100 acheived 00055 * 00056 * Revision 1.1.4.3 2004/12/09 22:31:57 pgm 00057 * microsecond timestamps do the BIZ - ECM20 here we go 00058 * 00059 * Revision 1.1.4.2 2004/12/09 12:58:34 pgm 00060 * various attempts at repartitioning for speed 00061 * 00062 * Revision 1.1.4.1 2004/11/04 07:13:13 pgm 00063 * merged multicard case 00064 * 00065 * Revision 1.1.2.7 2004/09/26 19:50:58 pgm 00066 * *** empty log message *** 00067 * 00068 * Revision 1.1.2.6 2004/09/26 11:32:39 pgm 00069 * multiboard tstats pollstats in 00070 * 00071 * Revision 1.1.2.5 2004/09/25 21:16:28 pgm 00072 * multiboard case runs 00073 * 00074 * Revision 1.1.2.4 2004/09/25 11:53:03 pgm 00075 * first pass multi done - check it works for n==1 00076 * 00077 * Revision 1.1.2.3 2004/09/25 09:12:35 pgm 00078 * *** empty log message *** 00079 * 00080 * Revision 1.1.2.2 2004/09/25 09:08:31 pgm 00081 * first UI/test split 00082 * 00083 * Revision 1.1.2.1 2004/09/25 08:46:04 pgm 00084 * *** empty log message *** 00085 * 00086 * Revision 1.1.2.1 2004/09/25 08:44:47 pgm 00087 * *** empty log message *** 00088 * 00089 */ 00090 00091 00092 /** @file llcontrol.h shared data structs for llcontrol. */ 00093 00094 #ifndef __LLCONTROL_H__ 00095 #define __LLCONTROL_H__ 00096 00097 extern int verbose; 00098 extern int G_quit; 00099 00100 #define MAXTEST 12 00101 00102 /** defines resources dedicated to each card. */ 00103 struct Card { 00104 int slot; 00105 int channels; 00106 struct MU* mbx; /* mapping to mailboxes on card */ 00107 struct DmaBuffer* buf; /* mapping of host-side buffer */ 00108 00109 unsigned tlatch; 00110 unsigned sync_2v_offset_status_hsbt; 00111 }; 00112 00113 /** defines timing of the shot. */ 00114 struct TimingStats { 00115 int iter; /** iteration. */ 00116 u32 tlatch; /** Tlatch: time the adc was clocked at. */ 00117 u32 tinst; /** Tinst: time the counter was read at. */ 00118 u32 tprocess; /** Process time on target */ 00119 int hb_poll; /** Host buffer poll count. 00120 * first card, indicates amount of slack time 00121 * other cards, should be small 00122 */ 00123 int target_poll; /* expect to be 1 for each card, a big number 00124 indicates that hb_poll mechanism failed */ 00125 u32 test_points[MAXTEST]; 00126 }; 00127 00128 00129 00130 #define ACQ196_BIGBUF_AREA 0x1000000 /* 16MB buffer assigned to each card */ 00131 #define MAXCARDS 16 00132 #define MAXAO32 6 /** Max AO32 Slave Cards */ 00133 00134 /** defines a test [shot] . */ 00135 struct TestDescription { 00136 enum Mode { 00137 M_NULL, /**< null test */ 00138 M_SCM, /**< Soft Clock Master */ 00139 M_ECS, /**< External Clock Slave */ 00140 M_ECM, /**< ECM External Clock Master */ 00141 M_SYNC_ECM, /**< ECM, sync AO update */ 00142 M_SYNC_2V, /**< ECM, 2 Vector sync */ 00143 M_SYNC_2VAO32, /**< ECM, 2 Vector sync + AO32 cards */ 00144 M_MEASURE_BRIDGE, /**< measure bridge latency */ 00145 M_SYNC_2VRFM /**< M_SYNC_2V, monitor at remote */ 00146 } mode; 00147 00148 struct ARG { 00149 int interval; /**< SCM: usecs delay */ 00150 int divisor; /**< ECM: external clock divisor */ 00151 } 00152 arg; 00153 int iter; /**< current iteration # */ 00154 00155 int iterations; /**< #samples to acquire */ 00156 int decimation; /**< {0..15} (0 won't do much!) */ 00157 int overwrite; /**< NOT append */ 00158 const char*outfname; /**< root name of output file (if output rqd)*/ 00159 int do_work; /**< do work (like read data in RT) */ 00160 int clkpos; /**< 1=> clock positive edge */ 00161 int trpos; /**< 1=> trigger positive edge */ 00162 int internal_loopback; 00163 int min_latency_test; /**< trim for abs minimum latency */ 00164 00165 int mask_ints; /**< optionally mask interrupts */ 00166 const char* mask_ints_mask; 00167 char* unmask_ints_mask; 00168 00169 int ncards; 00170 struct Card cards[MAXCARDS]; 00171 00172 struct TimingStats* stats_buf[MAXCARDS]; 00173 00174 void* work_buf[MAXCARDS]; 00175 00176 int samples; /* # samples per capture, default:1 */ 00177 int sample_size; 00178 int hb_polling; 00179 00180 int update_dacs; 00181 char* dac_data_file; 00182 char* dac_data; 00183 int dac_data_samples; 00184 int dac_cursor; 00185 00186 int feedback; 00187 int feedback_channel; 00188 00189 int tlog; /* log times if set */ 00190 const char* tlog_binfile; /* to this file */ 00191 int sample_offset; /* bytes to incr tgt point each smpl */ 00192 00193 int hardware_gate_off; /* gate off is using by hardware, so 00194 * don't poll for it */ 00195 u32 V2_BUFS[8]; 00196 00197 int ao32_count; 00198 int ao32_ids[MAXAO32]; 00199 00200 struct LLC200_INIT *llc200_init; 00201 int llc200_init_count; 00202 int acq216hs_ch12ch34_bonding; 00203 }; 00204 00205 #define LLC200_INIT_SZ sizeof(struct LLC200_INIT) 00206 00207 #define V2_NOBUF 1 /**< no buffer required, 0 offset may be valid! */ 00208 00209 #define IS_SYNC_2V(mode) \ 00210 ((mode) == M_SYNC_2V || (mode) == M_SYNC_2VAO32 || \ 00211 (mode) == M_SYNC_2VRFM) 00212 /* 00213 * define iterator for cards, assumes icard is a volatile variable 00214 * this is _much_ better represented in C++, see htstream for example 00215 */ 00216 00217 /* 00218 * iterator variable must be in scope for each call: 00219 */ 00220 #define EACHCARD(td) (&(td)->cards[icard]) 00221 #define EACHMBX(td) ((td)->cards[icard].mbx) 00222 #define EACHBUF(td) ((td)->cards[icard].buf) 00223 #define EACHSLOT(td) ((td)->cards[icard].slot) 00224 00225 /* 00226 * This is the iterator. WARNING: unsafe bracketing, easy to misuse! 00227 */ 00228 #define FOREACHCARD for (int icard = 0; icard != td->ncards; ++icard) 00229 00230 #define FIRSTCARD(td) (&(td)->cards[0]) 00231 #define FIRSTMBX(td) ((td)->cards[0].mbx) 00232 #define FIRSTBUF(td) ((td)->cards[0].buf) 00233 #define FIRSTSLOT(td) ((td)->cards[0].slot) 00234 00235 #define THIS_CARD icard 00236 #define MASTER (icard == 0) 00237 00238 /* 00239 * Core module EXPORTS these functions: 00240 */ 00241 00242 void setupAbortHandler( struct TestDescription* td ); 00243 void setupMonitor( int millisec ); 00244 void initCardResource(struct Card* card); 00245 /* 00246 * Code module IMPORTS these functions 00247 */ 00248 00249 00250 static inline int td_sample_size(struct TestDescription* td) 00251 { 00252 return td->sample_size; 00253 // return td->channels * sizeof(short); 00254 } 00255 static inline int td_dss(struct TestDescription* td) 00256 { 00257 return td_sample_size(td) * td->iterations; 00258 } 00259 00260 00261 void updateTimingStats( 00262 struct TimingStats* buffer, int iter, struct TimingStats* stats); 00263 #endif