00001 /***************************************************************************** 00002 * 00003 * File: llif.h 00004 * 00005 * $RCSfile: llif.h,v $ 00006 * 00007 * Copyright (C) 2001 D-TACQ Solutions Ltd 00008 * not to be used without owner's permission 00009 * 00010 * Description: interface to device driver - gets mappings for 00011 * control-mailboxes, and data-slave memory, 00012 * provides convenience functions for access 00013 * 00014 * $Id: llif.h,v 1.9.4.8 2006/01/19 20:15:28 pgm Exp $ 00015 * $Log: llif.h,v $ 00016 * Revision 1.9.4.8 2006/01/19 20:15:28 pgm 00017 * *** empty log message *** 00018 * 00019 * Revision 1.9.4.7 2006/01/15 15:04:26 pgm 00020 * *** empty log message *** 00021 * 00022 * Revision 1.9.4.6 2005/11/04 17:26:18 pgm 00023 * *** empty log message *** 00024 * 00025 * Revision 1.9.4.5 2004/11/04 07:13:13 pgm 00026 * merged multicard case 00027 * 00028 * Revision 1.9.4.4.2.2 2004/09/26 11:32:39 pgm 00029 * multiboard tstats pollstats in 00030 * 00031 * Revision 1.9.4.4.2.1 2004/09/25 11:53:03 pgm 00032 * first pass multi done - check it works for n==1 00033 * 00034 * Revision 1.9.4.4 2004/09/15 12:48:21 pgm 00035 * use internal var for llWaitDmaDone, reformat 00036 * 00037 * Revision 1.9.4.3 2004/07/31 21:48:25 pgm 00038 * now with Feedback - but why does it plot backwards\/ 00039 * 00040 * Revision 1.9.4.2 2004/07/27 20:49:06 pgm 00041 * llcontrol 2G with AO - in debug 00042 * 00043 * Revision 1.9.4.1 2004/07/25 20:39:38 pgm 00044 * hbpolling, 96 channels 00045 * 00046 * Revision 1.9 2002/09/25 09:50:49 pgm 00047 * opt to use bigbuf 00048 * 00049 * Revision 1.8 2002/09/02 15:36:14 pgm 00050 * hook up int masking 00051 * 00052 * Revision 1.7 2001/05/25 12:05:15 pgm 00053 * its a runner - shippit quick 00054 * 00055 * Revision 1.6 2001/05/21 17:42:38 pgm 00056 * reformed 00057 * 00058 * Revision 1.5 2001/05/20 21:24:10 pgm 00059 * ll WIP - almost works 00060 * 00061 * Revision 1.4 2001/05/19 19:46:15 pgm 00062 * enters LL mode with good bufs, mboxes 00063 * 00064 * Revision 1.3 2001/05/19 07:03:40 pgm 00065 * LL done for SOFT CLOCK, compiles 00066 * 00067 * Revision 1.2 2001/05/18 20:21:13 pgm 00068 * compiles. needs algorithms 00069 * 00070 * Revision 1.1 2001/05/18 07:09:37 pgm 00071 * first cut - wont compile :-( 00072 * 00073 * Revision 1.2 2000/12/28 11:03:00 pgm 00074 * *** empty log message *** 00075 * 00076 * Revision 1.1 1999/10/22 16:26:49 pgm 00077 * first entry to cvs 00078 * 00079 * 00080 \*****************************************************************************/ 00081 00082 /** @file llif.h interface to device driver. - gets mappings for 00083 * control-mailboxes, and data-slave memory, 00084 * provides convenience functions for access 00085 */ 00086 #ifndef __LLIF_H__ 00087 #define __LLIF_H__ 00088 00089 extern int verbose; 00090 00091 #define PRINTF( n ) if ( verbose>=(n) ) printf 00092 00093 #ifndef __U32__ 00094 typedef unsigned short u16; 00095 typedef unsigned u32; // define a 32 bit quantity 00096 #endif 00097 00098 /* 00099 * define interface to mailboxes. 00100 * struct MU is effectively "this" - much cleaner in C++!! 00101 * 00102 */ 00103 00104 typedef u32 MFA; /* Message Frame Address - unit of Q */ 00105 00106 00107 00108 00109 struct MU; /* Message Unit */ 00110 00111 00112 /** set a mail mbox register: ibox [0-3]. return 0 on success */ 00113 int setMbox( struct MU* m, int ibox, u32 value ); 00114 00115 00116 /** get contents of mailbox register: ibox [0-3] */ 00117 u32 getMbox( struct MU* m, int ibox ); 00118 00119 /** get last contents of mailbox register: ibox [0-3] */ 00120 u32 getMboxShadow(struct MU* m, int ibox ); 00121 00122 /** just set these bits. */ 00123 int setMboxBits( struct MU* m, int ibox, u32 bits_to_set ); 00124 00125 00126 /** just clr these bits. */ 00127 int clrMboxBits( struct MU* m, int ibox, u32 bits_to_clr ); 00128 00129 /** set the field in the register only. */ 00130 int setMboxField( struct MU* m, int ibox, u32 field_mask, u32 field_value ); 00131 00132 00133 /** return when any of the bits become true. */ 00134 u32 pollMboxBits( struct MU* m, int ibox, u32 mask, u32 goal ); 00135 00136 /** polls regular ack from acq32. */ 00137 int pollAck( struct MU* m ); 00138 00139 /** iboard [1-3]. return mapping on success. */ 00140 struct MU* mmapMbox( int iboard ); 00141 00142 00143 00144 void setMboxPollcount(struct MU* m, int poll_count); 00145 int getMboxPollcount(struct MU* m); 00146 00147 00148 void showLastWrites( struct MU* m ); 00149 00150 /** define interface to buffer memory. 00151 * again, for multiple boards this will be far more palatable as a C++ class 00152 */ 00153 struct DmaBuffer; /* opaque struct for clients */ 00154 00155 struct DmaBuffer* mmapDmaBuffer( int iboard, unsigned nbytes ); 00156 // maps dma buffer for board iboard {1..4}, nbytes long. ret mapping on success 00157 u32 getBusAddr( struct DmaBuffer* b, u32 offset ); 00158 u32* getVaddr( struct DmaBuffer* b, u32 offset ); 00159 int getDmaBufferLen(struct DmaBuffer* b); 00160 00161 00162 struct DmaBuffer* mmapBigBuffer( int iboard, unsigned nbytes ); 00163 // maps dma buffer from driver bigbuff section. 00164 00165 void mmapValidateDmaBuffer( struct MU* mbx, int nsamples ); 00166 // tell driver to allow normal data device access to red dmabuffer 00167 00168 00169 00170 void acq32_enableInts( struct MU* mbx, unsigned mask ); 00171 void acq32_maskInts ( struct MU* mbx, unsigned mask ); 00172 00173 /* 00174 * hbPolling - place a marker in Host Buffer, poll for overwrite 00175 */ 00176 int hbPoll(struct DmaBuffer *buf, int offset, 00177 int sample_len, volatile int* user_abort); 00178 void hbPrimePoll(struct DmaBuffer *buf, int offset, int sample_len); 00179 void hbPrimeBuffer(struct DmaBuffer *buf); 00180 00181 00182 /** 00183 * I2O Q ports: 00184 * OUTBOUND: host reserves free MFA, puts MFA as command 00185 * INBOUND: host gets message MFA, replaces MFA when done 00186 * 00187 * NB: direction with respect to HOST! 00188 */ 00189 00190 MFA mu_reserveOutbound(struct MU* mu); 00191 int mu_putOutbound(struct MU* mu, MFA mfa); 00192 /* return 0 on success */ 00193 00194 MFA mu_getInbound(struct MU* mu); 00195 int mu_returnInbound(struct MU* mu, MFA mfa); 00196 00197 00198 00199 static inline void memset32(u32 *buf, u32 value, int count) 00200 { 00201 int ii; 00202 00203 for (ii = 0; ii < count; ++ii){ 00204 buf[ii] = value; 00205 } 00206 } 00207 00208 00209 00210 #define MFA_FAIL 0xffffffff 00211 #endif