LLC2_API
local.h
Go to the documentation of this file.
00001 #define pgm_getchar getchar
00002 #ifdef __arm
00003 
00004 // KLUDGE time - arm works with rev1.8
00005 
00006 /*****************************************************************************
00007  *
00008  * File: local.h
00009  *
00010  * $RCSfile: local.h,v $
00011  * 
00012  * Copyright (C) 1999 D-TACQ Solutions Ltd
00013  * not to be used without owner's permission
00014  *
00015  * Description:
00016  *
00017  * $Id: local.h,v 1.19.4.4 2006/01/15 11:21:54 pgm Exp $
00018  * $Log: local.h,v $
00019  * Revision 1.19.4.4  2006/01/15 11:21:54  pgm
00020  * *** empty log message ***
00021  *
00022  * Revision 1.19.4.3  2003/10/30 14:13:46  pgm
00023  * *** empty log message ***
00024  *
00025  * Revision 1.19.4.2  2003/10/04 17:31:19  pgm
00026  * RH9 switch for pesky remap vma
00027  *
00028  * Revision 1.19.4.1  2003/09/08 21:12:06  pgm
00029  * *** empty log message ***
00030  *
00031  * Revision 1.19  2002/11/03 21:41:49  pgm
00032  * *** empty log message ***
00033  *
00034  * Revision 1.17  2002/03/14 12:03:48  pgm
00035  * compiled on benbecula
00036  *
00037  * Revision 1.16  2002/01/04 17:35:32  pgm
00038  * LINUX_NEW_PCI th now 2.2.16
00039  *
00040  * Revision 1.15  2001/12/21 21:35:47  pgm
00041  * *** empty log message ***
00042  *
00043  * Revision 1.14  2001/12/21 21:32:46  pgm
00044  * LINUX_NEW_PCI
00045  *
00046  * Revision 1.13  2001/08/19 19:23:02  pgm
00047  * Alpha builds
00048  *
00049  * Revision 1.12  2001/08/12 08:30:04  pgm
00050  * user LED control
00051  *
00052  * Revision 1.11  2001/04/14 20:37:51  pgm
00053  * CPCI routing coded, needs testing
00054  *
00055  * Revision 1.10  2001/04/10 19:14:19  pgm
00056  * fixed for arm too
00057  *
00058  * Revision 1.9  2001/04/10 19:11:01  pgm
00059  * kludge to enable arm+Linux from same version
00060  *
00061  * Revision 1.8  2001/03/18 17:38:44  pgm
00062  * builds with max 2 warnings
00063  *
00064  * Revision 1.7  2001/02/16 21:38:41  pgm
00065  * update from arm side
00066  *
00067  * Revision 1.6  2001/02/16 21:37:21  pgm
00068  * update from arm side
00069  *
00070  * Revision 1.5  2000/07/01 07:26:46  pgm
00071  * keep this one, it works better
00072  *
00073  * Revision 1.3  1999/10/28 13:36:39  pgm
00074  * assign bits in priority order
00075  *
00076  * Revision 1.2  1999/10/16 07:24:12  pgm
00077  * *** empty log message ***
00078  *
00079  * Revision 1.1  1999/10/01 09:36:32  pgm
00080  * *** empty log message ***
00081  *
00082  *
00083 \*****************************************************************************/
00084 
00085 
00086 
00087 #ifndef _LOCAL_H_
00088 #define _LOCAL_H_
00089 
00090 
00091 /*
00092  * String Handling
00093  */
00094 
00095 #ifndef __KERNEL__
00096 #include <string.h>
00097 #endif
00098 
00099 #define STREQ( s1, s2 )        (strcmp( s1, s2 ) == 0)
00100 #define STREQN( s1, s2, n )    (strncmp( s1, s2, n ) == 0) 
00101 #define STREQNL( s1, s2 )      (strncmp( s1, s2, strlen(s2) ) == 0)
00102 
00103 #define ATOL( s1 )    (unsigned)strtoul( s1, NULL, 0 )
00104 
00105 
00106 /*
00107  * Range Checking and simple math
00108  */
00109 
00110 #define IN_RANGE(xx,ll,rr)      ((xx)>=(ll)&&(xx)<=(rr))
00111 #define CLAMP(xx,ll,rr)         ((xx) = (xx)<(ll)? (ll): (xx)>(rr)? (rr): (xx))
00112 #define SWAP(aa,bb,tt)  ( tt = aa, aa = bb, bb = tt )
00113 
00114 #define MAX(aa,bb)      ((aa)>=(bb)?(aa):(bb))
00115 #define MIN(aa,bb)      ((aa)<=(bb)?(aa):(bb))
00116 
00117 
00118 #define ABS(aa)                 ((aa)>0?(aa):-(aa))
00119 #define SQR(aa)                 ((aa)*(aa))
00120 #define SIGN(aa)                ((aa)>=0? 1: -1)
00121 
00122 
00123 /*
00124  * boolean values
00125  */
00126 
00127 #ifndef OK
00128 #define OK      0
00129 #endif
00130 #ifndef ERR
00131 #define ERR    -1
00132 #endif
00133 #ifndef FALSE
00134 #define FALSE   0
00135 #endif
00136 #ifndef TRUE
00137 #define TRUE    1
00138 #endif
00139 #ifndef ON
00140 #define ON      1
00141 #endif
00142 #ifndef OFF
00143 #define OFF     0
00144 #endif
00145 
00146 extern int P_debug;
00147 
00148 #define PRINTF    if ( P_debug ) printf
00149 #define PRINTFL(n) if ( P_debug > n ) printf
00150 #define PRINTID PRINTF( __FILE__ ":%d\n", __LINE__ )
00151 
00152 #define ST_PRINTF    if ( P_debug<0) printf
00153 
00154 #define SUCCESS   1
00155 #define FAIL      (!SUCCESS)
00156 
00157 
00158 
00159 extern void makeAssertion( char* file, int line );
00160 
00161 #define ARM_ASSERT( cond ) \
00162         if (!(cond)) makeAssertion( __FILE__, __LINE__ )
00163 
00164 
00165 /*
00166  * useful constants
00167  */
00168 
00169 #define KB    0x400
00170 #define MB    0x100000
00171 
00172 
00173 #define WORKTODO (-1)
00174 #ifdef __arm
00175 
00176 #ifndef NO_PGM_PRINTF
00177 
00178 extern int pgm_printf( char fmt[], ... );
00179 extern int pgm_fgets( char buf[], int maxbuf );
00180 
00181 #define printf                  pgm_printf
00182 #define fflush( stream )
00183 #define fgets( a, b, c )        pgm_fgets( a, b )
00184 
00185 #endif // NO_PGM_PRINTF
00186 
00187 #endif                  // __arm
00188 
00189 typedef unsigned       u32;
00190 typedef unsigned short u16;
00191 typedef unsigned char  u8;
00192 
00193 #endif    /* _LOCAL_H_ */
00194 
00195 
00196 #else // __arm ... the else is all but arm
00197 
00198 /*****************************************************************************
00199  *
00200  * File: local.h
00201  *
00202  * $RCSfile: local.h,v $
00203  * 
00204  * Copyright (C) 1999 D-TACQ Solutions Ltd
00205  * not to be used without owner's permission
00206  *
00207  * Description:
00208  *
00209  * $Id: local.h,v 1.19.4.4 2006/01/15 11:21:54 pgm Exp $
00210  * $Log: local.h,v $
00211  * Revision 1.19.4.4  2006/01/15 11:21:54  pgm
00212  * *** empty log message ***
00213  *
00214  * Revision 1.19.4.3  2003/10/30 14:13:46  pgm
00215  * *** empty log message ***
00216  *
00217  * Revision 1.19.4.2  2003/10/04 17:31:19  pgm
00218  * RH9 switch for pesky remap vma
00219  *
00220  * Revision 1.19.4.1  2003/09/08 21:12:06  pgm
00221  * *** empty log message ***
00222  *
00223  * Revision 1.19  2002/11/03 21:41:49  pgm
00224  * *** empty log message ***
00225  *
00226  * Revision 1.17  2002/03/14 12:03:48  pgm
00227  * compiled on benbecula
00228  *
00229  * Revision 1.16  2002/01/04 17:35:32  pgm
00230  * LINUX_NEW_PCI th now 2.2.16
00231  *
00232  * Revision 1.15  2001/12/21 21:35:47  pgm
00233  * *** empty log message ***
00234  *
00235  * Revision 1.14  2001/12/21 21:32:46  pgm
00236  * LINUX_NEW_PCI
00237  *
00238  * Revision 1.13  2001/08/19 19:23:02  pgm
00239  * Alpha builds
00240  *
00241  * Revision 1.12  2001/08/12 08:30:04  pgm
00242  * user LED control
00243  *
00244  * Revision 1.11  2001/04/14 20:37:51  pgm
00245  * CPCI routing coded, needs testing
00246  *
00247  * Revision 1.10  2001/04/10 19:14:19  pgm
00248  * fixed for arm too
00249  *
00250  * Revision 1.9  2001/04/10 19:11:01  pgm
00251  * kludge to enable arm+Linux from same version
00252  *
00253  * Revision 1.3  1999/10/28 13:36:39  pgm
00254  * assign bits in priority order
00255  *
00256  * Revision 1.2  1999/10/16 07:24:12  pgm
00257  * *** empty log message ***
00258  *
00259  * Revision 1.1  1999/10/01 09:36:32  pgm
00260  * *** empty log message ***
00261  *
00262  *
00263 \*****************************************************************************/
00264 
00265 #ifndef _LOCAL_H_
00266 #define _LOCAL_H_
00267 
00268 
00269 #ifdef __KERNEL__
00270 #include <linux/version.h>
00271 
00272 #ifndef VERSION_CODE
00273 #  define VERSION_CODE(vers,rel,seq) ( ((vers)<<16) | ((rel)<<8) | (seq) )
00274 #endif
00275 
00276 /* only allow 2.0.x and 2.1.y */
00277 /*
00278 #if LINUX_VERSION_CODE > VERSION_CODE(2,2,16)
00279 #define LINUX_NEW_PCI
00280 #endif
00281 */
00282 #if LINUX_VERSION_CODE > VERSION_CODE(2,4,18)
00283 #define RH9
00284 #endif
00285 /*
00286  * String Handling
00287  */
00288 
00289 
00290 #if (LINUX_VERSION_CODE < 0x020600)
00291 #error NO KERNEL_26
00292 #include <asm/current.h>    // this reaches the parts for ALPHA
00293 #endif
00294 #endif /* __KERNEL__ */
00295 
00296 
00297 
00298 #ifndef __KERNEL__
00299 #include <string.h>
00300 #endif
00301 
00302 #define STREQ( s1, s2 )        (strcmp( s1, s2 ) == 0)
00303 #define STREQN( s1, s2, n )    (strncmp( s1, s2, n ) == 0) 
00304 #define STREQNL( s1, s2 )      (strncmp( s1, s2, strlen(s2) ) == 0)
00305 
00306 
00307 /*
00308  * Range Checking and simple math
00309  */
00310 
00311 #define IN_RANGE(xx,ll,rr)      ((xx)>=(ll)&&(xx)<=(rr))
00312 #define CLAMP(xx,ll,rr)         ((xx) = (xx)<(ll)? (ll): (xx)>(rr)? (rr): (xx))
00313 #define SWAP(aa,bb,tt)  ( tt = aa, aa = bb, bb = tt )
00314 
00315 #define MAX(aa,bb)      ((aa)>=(bb)?(aa):(bb))
00316 #define MIN(aa,bb)      ((aa)<=(bb)?(aa):(bb))
00317 
00318 
00319 #define ABS(aa)                 ((aa)>=0?(aa):-(aa))
00320 #define SQR(aa)                 ((aa)*(aa))
00321 #define SIGN(aa)                ((aa)>=0? 1: -1)
00322 
00323 
00324 /*
00325  * boolean values
00326  */
00327 
00328 #ifndef OK
00329 #define OK      0
00330 #endif
00331 #ifndef ERR
00332 #define ERR    -1
00333 #endif
00334 #ifndef FALSE
00335 #define FALSE   0
00336 #endif
00337 #ifndef TRUE
00338 #define TRUE    1
00339 #endif
00340 #ifndef ON
00341 #define ON      1
00342 #endif
00343 #ifndef OFF
00344 #define OFF     0
00345 #endif
00346 
00347 
00348 /*
00349  * Printing Debugs
00350  */
00351 
00352 #undef PDEBUG             /* undef it, just in case */
00353 
00354 #ifndef NDEBUG
00355 #  ifdef __KERNEL__
00356 /* This one if debugging is on, and kernel space */
00357 #    define PDEBUG(fmt, args...) printk( KERN_DEBUG "acq32: " fmt, ## args)
00358 #  else
00359 /* This one for user space */
00360 #    define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
00361 #  endif
00362 #else
00363 #  define PDEBUG(fmt, args...) /* not debugging: nothing */
00364 #endif
00365 
00366 #undef PDEBUGG
00367 #define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */
00368 
00369 
00370 /*
00371  * useful constants
00372  */
00373 
00374 #define KB    0x400
00375 #define MB    0x100000
00376 
00377 /*
00378  * Assertions
00379  */
00380 
00381 #ifndef NDEBUG
00382 #   ifdef __KERNEL__
00383 
00384 /*
00385  * spins after assert. NOT ideal. we really want to die
00386  * would kill_proc( current->pid, SIG_QUIT, 0 ) do the biz?
00387  */
00388 #       define ASSERT( cond ) \
00389                    if ( !(cond) ){ \
00390                        PDEBUG( "ASSERTION: %s %d", __FILE__, __LINE__ );\
00391                        while(1) schedule();\
00392                    }
00393 #   else
00394 #       define ASSERT( cond ) \
00395             if ( !(cond) ){ \
00396                 fprintf( stderr, "ASSERTION: %s %d",__FILE__,__LINE__ );\
00397                 exit( 1 );\
00398             }
00399 #   endif
00400 #else
00401 #   define ASSERT( cond )
00402 #endif // NDEBUG
00403 
00404 #define WORKTODO (-1)
00405 
00406 #endif    /* _LOCAL_H_ */
00407 
00408 
00409 
00410 #endif //_arm
00411 
00412 
00413 
00414 
00415 
00416 
00417 
00418 
00419 
00420 
00421 
00422