| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 |  | 
|  | 2 | /* | 
|  | 3 | * | 
|  | 4 | Copyright (c) Eicon Networks, 2002. | 
|  | 5 | * | 
|  | 6 | This source file is supplied for the use with | 
|  | 7 | Eicon Networks range of DIVA Server Adapters. | 
|  | 8 | * | 
|  | 9 | Eicon File Revision :    2.1 | 
|  | 10 | * | 
|  | 11 | This program is free software; you can redistribute it and/or modify | 
|  | 12 | it under the terms of the GNU General Public License as published by | 
|  | 13 | the Free Software Foundation; either version 2, or (at your option) | 
|  | 14 | any later version. | 
|  | 15 | * | 
|  | 16 | This program is distributed in the hope that it will be useful, | 
|  | 17 | but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY | 
|  | 18 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 
|  | 19 | See the GNU General Public License for more details. | 
|  | 20 | * | 
|  | 21 | You should have received a copy of the GNU General Public License | 
|  | 22 | along with this program; if not, write to the Free Software | 
|  | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
|  | 24 | * | 
|  | 25 | */ | 
|  | 26 | #if !defined(__DEBUGLIB_H__) | 
|  | 27 | #define __DEBUGLIB_H__ | 
|  | 28 | #include <stdarg.h> | 
|  | 29 | /* | 
|  | 30 | * define global debug priorities | 
|  | 31 | */ | 
|  | 32 | #define DL_LOG  0x00000001 /* always worth mentioning */ | 
|  | 33 | #define DL_FTL  0x00000002 /* always sampled error    */ | 
|  | 34 | #define DL_ERR  0x00000004 /* any kind of error       */ | 
|  | 35 | #define DL_TRC  0x00000008 /* verbose information     */ | 
|  | 36 | #define DL_XLOG  0x00000010 /* old xlog info           */ | 
|  | 37 | #define DL_MXLOG 0x00000020 /* maestra xlog info    */ | 
|  | 38 | #define DL_FTL_MXLOG 0x00000021 /* fatal maestra xlog info */ | 
|  | 39 | #define DL_EVL  0x00000080 /* special NT eventlog msg */ | 
|  | 40 | #define DL_COMPAT (DL_MXLOG | DL_XLOG) | 
|  | 41 | #define DL_PRIOR_MASK (DL_EVL | DL_COMPAT | DL_TRC | DL_ERR | DL_FTL | DL_LOG) | 
|  | 42 | #define DLI_LOG  0x0100 | 
|  | 43 | #define DLI_FTL  0x0200 | 
|  | 44 | #define DLI_ERR  0x0300 | 
|  | 45 | #define DLI_TRC  0x0400 | 
|  | 46 | #define DLI_XLOG 0x0500 | 
|  | 47 | #define DLI_MXLOG 0x0600 | 
|  | 48 | #define DLI_FTL_MXLOG 0x0600 | 
|  | 49 | #define DLI_EVL  0x0800 | 
|  | 50 | /* | 
|  | 51 | * define OS (operating system interface) debuglevel | 
|  | 52 | */ | 
|  | 53 | #define DL_REG  0x00000100 /* init/query registry     */ | 
|  | 54 | #define DL_MEM  0x00000200 /* memory management       */ | 
|  | 55 | #define DL_SPL  0x00000400 /* event/spinlock handling */ | 
|  | 56 | #define DL_IRP  0x00000800 /* I/O request handling    */ | 
|  | 57 | #define DL_TIM  0x00001000 /* timer/watchdog handling */ | 
|  | 58 | #define DL_BLK  0x00002000 /* raw data block contents */ | 
|  | 59 | #define DL_OS_MASK (DL_BLK | DL_TIM | DL_IRP | DL_SPL | DL_MEM | DL_REG) | 
|  | 60 | #define DLI_REG  0x0900 | 
|  | 61 | #define DLI_MEM  0x0A00 | 
|  | 62 | #define DLI_SPL  0x0B00 | 
|  | 63 | #define DLI_IRP  0x0C00 | 
|  | 64 | #define DLI_TIM  0x0D00 | 
|  | 65 | #define DLI_BLK  0x0E00 | 
|  | 66 | /* | 
|  | 67 | * define ISDN (connection interface) debuglevel | 
|  | 68 | */ | 
|  | 69 | #define DL_TAPI  0x00010000 /* debug TAPI interface    */ | 
|  | 70 | #define DL_NDIS  0x00020000 /* debug NDIS interface    */ | 
|  | 71 | #define DL_CONN  0x00040000 /* connection handling     */ | 
|  | 72 | #define DL_STAT  0x00080000 /* trace state machines    */ | 
|  | 73 | #define DL_SEND  0x00100000 /* trace raw xmitted data  */ | 
|  | 74 | #define DL_RECV  0x00200000 /* trace raw received data */ | 
|  | 75 | #define DL_DATA  (DL_SEND | DL_RECV) | 
|  | 76 | #define DL_ISDN_MASK (DL_DATA | DL_STAT | DL_CONN | DL_NDIS | DL_TAPI) | 
|  | 77 | #define DLI_TAPI 0x1100 | 
|  | 78 | #define DLI_NDIS 0x1200 | 
|  | 79 | #define DLI_CONN 0x1300 | 
|  | 80 | #define DLI_STAT 0x1400 | 
|  | 81 | #define DLI_SEND 0x1500 | 
|  | 82 | #define DLI_RECV 0x1600 | 
|  | 83 | /* | 
|  | 84 | * define some private (unspecified) debuglevel | 
|  | 85 | */ | 
|  | 86 | #define DL_PRV0  0x01000000 | 
|  | 87 | #define DL_PRV1  0x02000000 | 
|  | 88 | #define DL_PRV2  0x04000000 | 
|  | 89 | #define DL_PRV3  0x08000000 | 
|  | 90 | #define DL_PRIV_MASK (DL_PRV0 | DL_PRV1 | DL_PRV2 | DL_PRV3) | 
|  | 91 | #define DLI_PRV0 0x1900 | 
|  | 92 | #define DLI_PRV1 0x1A00 | 
|  | 93 | #define DLI_PRV2 0x1B00 | 
|  | 94 | #define DLI_PRV3 0x1C00 | 
|  | 95 | #define DT_INDEX(x)  ((x) & 0x000F) | 
|  | 96 | #define DL_INDEX(x)  ((((x) >> 8) & 0x00FF) - 1) | 
|  | 97 | #define DLI_NAME(x)  ((x) & 0xFF00) | 
|  | 98 | /* | 
|  | 99 | * Debug mask for kernel mode tracing, if set the output is also sent to | 
|  | 100 | * the system debug function. Requires that the project is compiled | 
|  | 101 | * with _KERNEL_DBG_PRINT_ | 
|  | 102 | */ | 
|  | 103 | #define DL_TO_KERNEL    0x40000000 | 
|  | 104 |  | 
|  | 105 | #ifdef DIVA_NO_DEBUGLIB | 
|  | 106 | #define myDbgPrint_LOG(x...) do { } while(0); | 
|  | 107 | #define myDbgPrint_FTL(x...) do { } while(0); | 
|  | 108 | #define myDbgPrint_ERR(x...) do { } while(0); | 
|  | 109 | #define myDbgPrint_TRC(x...) do { } while(0); | 
|  | 110 | #define myDbgPrint_MXLOG(x...) do { } while(0); | 
|  | 111 | #define myDbgPrint_EVL(x...) do { } while(0); | 
|  | 112 | #define myDbgPrint_REG(x...) do { } while(0); | 
|  | 113 | #define myDbgPrint_MEM(x...) do { } while(0); | 
|  | 114 | #define myDbgPrint_SPL(x...) do { } while(0); | 
|  | 115 | #define myDbgPrint_IRP(x...) do { } while(0); | 
|  | 116 | #define myDbgPrint_TIM(x...) do { } while(0); | 
|  | 117 | #define myDbgPrint_BLK(x...) do { } while(0); | 
|  | 118 | #define myDbgPrint_TAPI(x...) do { } while(0); | 
|  | 119 | #define myDbgPrint_NDIS(x...) do { } while(0); | 
|  | 120 | #define myDbgPrint_CONN(x...) do { } while(0); | 
|  | 121 | #define myDbgPrint_STAT(x...) do { } while(0); | 
|  | 122 | #define myDbgPrint_SEND(x...) do { } while(0); | 
|  | 123 | #define myDbgPrint_RECV(x...) do { } while(0); | 
|  | 124 | #define myDbgPrint_PRV0(x...) do { } while(0); | 
|  | 125 | #define myDbgPrint_PRV1(x...) do { } while(0); | 
|  | 126 | #define myDbgPrint_PRV2(x...) do { } while(0); | 
|  | 127 | #define myDbgPrint_PRV3(x...) do { } while(0); | 
|  | 128 | #define DBG_TEST(func,args) do { } while(0); | 
|  | 129 | #define DBG_EVL_ID(args) do { } while(0); | 
|  | 130 |  | 
|  | 131 | #else /* DIVA_NO_DEBUGLIB */ | 
|  | 132 | /* | 
|  | 133 | * define low level macros for formatted & raw debugging | 
|  | 134 | */ | 
|  | 135 | #define DBG_DECL(func) extern void  myDbgPrint_##func (char *, ...) ; | 
|  | 136 | DBG_DECL(LOG) | 
|  | 137 | DBG_DECL(FTL) | 
|  | 138 | DBG_DECL(ERR) | 
|  | 139 | DBG_DECL(TRC) | 
|  | 140 | DBG_DECL(MXLOG) | 
|  | 141 | DBG_DECL(FTL_MXLOG) | 
|  | 142 | extern void  myDbgPrint_EVL (long, ...) ; | 
|  | 143 | DBG_DECL(REG) | 
|  | 144 | DBG_DECL(MEM) | 
|  | 145 | DBG_DECL(SPL) | 
|  | 146 | DBG_DECL(IRP) | 
|  | 147 | DBG_DECL(TIM) | 
|  | 148 | DBG_DECL(BLK) | 
|  | 149 | DBG_DECL(TAPI) | 
|  | 150 | DBG_DECL(NDIS) | 
|  | 151 | DBG_DECL(CONN) | 
|  | 152 | DBG_DECL(STAT) | 
|  | 153 | DBG_DECL(SEND) | 
|  | 154 | DBG_DECL(RECV) | 
|  | 155 | DBG_DECL(PRV0) | 
|  | 156 | DBG_DECL(PRV1) | 
|  | 157 | DBG_DECL(PRV2) | 
|  | 158 | DBG_DECL(PRV3) | 
|  | 159 | #ifdef  _KERNEL_DBG_PRINT_ | 
|  | 160 | /* | 
|  | 161 | * tracing to maint and kernel if selected in the trace mask. | 
|  | 162 | */ | 
|  | 163 | #define DBG_TEST(func,args) \ | 
|  | 164 | { if ( (myDriverDebugHandle.dbgMask) & (unsigned long)DL_##func ) \ | 
|  | 165 | { \ | 
|  | 166 | if ( (myDriverDebugHandle.dbgMask) & DL_TO_KERNEL ) \ | 
|  | 167 | {DbgPrint args; DbgPrint ("\r\n");} \ | 
|  | 168 | myDbgPrint_##func args ; \ | 
|  | 169 | } } | 
|  | 170 | #else | 
|  | 171 | /* | 
|  | 172 | * Standard tracing to maint driver. | 
|  | 173 | */ | 
|  | 174 | #define DBG_TEST(func,args) \ | 
|  | 175 | { if ( (myDriverDebugHandle.dbgMask) & (unsigned long)DL_##func ) \ | 
|  | 176 | { myDbgPrint_##func args ; \ | 
|  | 177 | } } | 
|  | 178 | #endif | 
|  | 179 | /* | 
| Joe Perches | c66ed65 | 2008-02-03 17:16:28 +0200 | [diff] [blame] | 180 | * For event level debug use a separate define, the parameter are | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | * different and cause compiler errors on some systems. | 
|  | 182 | */ | 
|  | 183 | #define DBG_EVL_ID(args) \ | 
|  | 184 | { if ( (myDriverDebugHandle.dbgMask) & (unsigned long)DL_EVL ) \ | 
|  | 185 | { myDbgPrint_EVL args ; \ | 
|  | 186 | } } | 
|  | 187 |  | 
|  | 188 | #endif /* DIVA_NO_DEBUGLIB */ | 
|  | 189 |  | 
|  | 190 | #define DBG_LOG(args)  DBG_TEST(LOG, args) | 
|  | 191 | #define DBG_FTL(args)  DBG_TEST(FTL, args) | 
|  | 192 | #define DBG_ERR(args)  DBG_TEST(ERR, args) | 
|  | 193 | #define DBG_TRC(args)  DBG_TEST(TRC, args) | 
|  | 194 | #define DBG_MXLOG(args)  DBG_TEST(MXLOG, args) | 
|  | 195 | #define DBG_FTL_MXLOG(args) DBG_TEST(FTL_MXLOG, args) | 
|  | 196 | #define DBG_EVL(args)  DBG_EVL_ID(args) | 
|  | 197 | #define DBG_REG(args)  DBG_TEST(REG, args) | 
|  | 198 | #define DBG_MEM(args)  DBG_TEST(MEM, args) | 
|  | 199 | #define DBG_SPL(args)  DBG_TEST(SPL, args) | 
|  | 200 | #define DBG_IRP(args)  DBG_TEST(IRP, args) | 
|  | 201 | #define DBG_TIM(args)  DBG_TEST(TIM, args) | 
|  | 202 | #define DBG_BLK(args)  DBG_TEST(BLK, args) | 
|  | 203 | #define DBG_TAPI(args)  DBG_TEST(TAPI, args) | 
|  | 204 | #define DBG_NDIS(args)  DBG_TEST(NDIS, args) | 
|  | 205 | #define DBG_CONN(args)  DBG_TEST(CONN, args) | 
|  | 206 | #define DBG_STAT(args)  DBG_TEST(STAT, args) | 
|  | 207 | #define DBG_SEND(args)  DBG_TEST(SEND, args) | 
|  | 208 | #define DBG_RECV(args)  DBG_TEST(RECV, args) | 
|  | 209 | #define DBG_PRV0(args)  DBG_TEST(PRV0, args) | 
|  | 210 | #define DBG_PRV1(args)  DBG_TEST(PRV1, args) | 
|  | 211 | #define DBG_PRV2(args)  DBG_TEST(PRV2, args) | 
|  | 212 | #define DBG_PRV3(args)  DBG_TEST(PRV3, args) | 
|  | 213 | /* | 
|  | 214 | * prototypes for debug register/deregister functions in "debuglib.c" | 
|  | 215 | */ | 
|  | 216 | #ifdef DIVA_NO_DEBUGLIB | 
|  | 217 | #define DbgRegister(name,tag, mask) do { } while(0) | 
|  | 218 | #define DbgDeregister() do { } while(0) | 
|  | 219 | #define DbgSetLevel(mask) do { } while(0) | 
|  | 220 | #else | 
|  | 221 | extern DIVA_DI_PRINTF dprintf; | 
|  | 222 | extern int  DbgRegister (char *drvName, char *drvTag, unsigned long dbgMask) ; | 
|  | 223 | extern void DbgDeregister (void) ; | 
|  | 224 | extern void DbgSetLevel (unsigned long dbgMask) ; | 
|  | 225 | #endif | 
|  | 226 | /* | 
|  | 227 | * driver internal structure for debug handling; | 
|  | 228 | * in client drivers this structure is maintained in "debuglib.c", | 
|  | 229 | * in the debug driver "debug.c" maintains a chain of such structs. | 
|  | 230 | */ | 
|  | 231 | typedef struct _DbgHandle_ *pDbgHandle ; | 
|  | 232 | typedef void ( * DbgEnd) (pDbgHandle) ; | 
|  | 233 | typedef void ( * DbgLog) (unsigned short, int, char *, va_list) ; | 
|  | 234 | typedef void ( * DbgOld) (unsigned short, char *, va_list) ; | 
|  | 235 | typedef void ( * DbgEv)  (unsigned short, unsigned long, va_list) ; | 
|  | 236 | typedef void ( * DbgIrq) (unsigned short, int, char *, va_list) ; | 
|  | 237 | typedef struct _DbgHandle_ | 
|  | 238 | { char    Registered ; /* driver successfull registered */ | 
|  | 239 | #define DBG_HANDLE_REG_NEW 0x01  /* this (new) structure    */ | 
|  | 240 | #define DBG_HANDLE_REG_OLD 0x7f  /* old structure (see below)  */ | 
|  | 241 | char    Version;  /* version of this structure  */ | 
|  | 242 | #define DBG_HANDLE_VERSION 1   /* contains dbg_old function now */ | 
|  | 243 | #define DBG_HANDLE_VER_EXT  2           /* pReserved points to extended info*/ | 
|  | 244 | short               id ;   /* internal id of registered driver */ | 
|  | 245 | struct _DbgHandle_ *next ;   /* ptr to next registered driver    */ | 
|  | 246 | struct /*LARGE_INTEGER*/ { | 
|  | 247 | unsigned long LowPart; | 
|  | 248 | long          HighPart; | 
|  | 249 | }     regTime ;  /* timestamp for registration       */ | 
|  | 250 | void               *pIrp ;   /* ptr to pending i/o request       */ | 
|  | 251 | unsigned long       dbgMask ;  /* current debug mask               */ | 
|  | 252 | char                drvName[16] ; /* ASCII name of registered driver  */ | 
|  | 253 | char                drvTag[64] ; /* revision string     */ | 
|  | 254 | DbgEnd              dbg_end ;  /* function for debug closing       */ | 
|  | 255 | DbgLog              dbg_prt ;  /* function for debug appending     */ | 
|  | 256 | DbgOld              dbg_old ;  /* function for old debug appending */ | 
|  | 257 | DbgEv       dbg_ev ;  /* function for Windows NT Eventlog */ | 
|  | 258 | DbgIrq    dbg_irq ;  /* function for irql checked debug  */ | 
|  | 259 | void      *pReserved3 ; | 
|  | 260 | } _DbgHandle_ ; | 
|  | 261 | extern _DbgHandle_ myDriverDebugHandle ; | 
|  | 262 | typedef struct _OldDbgHandle_ | 
|  | 263 | { struct _OldDbgHandle_ *next ; | 
|  | 264 | void                *pIrp ; | 
|  | 265 | long    regTime[2] ; | 
|  | 266 | unsigned long       dbgMask ; | 
|  | 267 | short               id ; | 
|  | 268 | char                drvName[78] ; | 
|  | 269 | DbgEnd              dbg_end ; | 
|  | 270 | DbgLog              dbg_prt ; | 
|  | 271 | } _OldDbgHandle_ ; | 
|  | 272 | /* the differences in DbgHandles | 
|  | 273 | old:    tmp:     new: | 
|  | 274 | 0 long next  char Registered  char Registered | 
|  | 275 | char filler   char Version | 
|  | 276 | short id    short id | 
|  | 277 | 4 long pIrp  long    regTime.lo  long next | 
|  | 278 | 8 long    regTime.lo long    regTime.hi  long    regTime.lo | 
|  | 279 | 12 long    regTime.hi long next   long regTime.hi | 
|  | 280 | 16 long dbgMask  long pIrp   long pIrp | 
|  | 281 | 20 short id   long dbgMask   long dbgMask | 
|  | 282 | 22 char    drvName[78] .. | 
|  | 283 | 24 ..     char drvName[16]  char drvName[16] | 
|  | 284 | 40 ..     char drvTag[64]  char drvTag[64] | 
|  | 285 | 100 void *dbg_end ..      .. | 
|  | 286 | 104 void *dbg_prt void *dbg_end  void *dbg_end | 
|  | 287 | 108 ..     void *dbg_prt  void *dbg_prt | 
|  | 288 | 112 ..     ..      void *dbg_old | 
|  | 289 | 116 ..     ..      void *dbg_ev | 
|  | 290 | 120 ..     ..      void *dbg_irq | 
|  | 291 | 124 ..     ..      void *pReserved3 | 
|  | 292 | ( new->id == 0 && *((short *)&new->dbgMask) == -1 ) identifies "old", | 
|  | 293 | new->Registered and new->Version overlay old->next, | 
|  | 294 | new->next overlays old->pIrp, new->regTime matches old->regTime and | 
|  | 295 | thus these fields can be maintained in new struct whithout trouble; | 
|  | 296 | id, dbgMask, drvName, dbg_end and dbg_prt need special handling ! | 
|  | 297 | */ | 
|  | 298 | #define DBG_EXT_TYPE_CARD_TRACE     0x00000001 | 
|  | 299 | typedef struct | 
|  | 300 | { | 
|  | 301 | unsigned long       ExtendedType; | 
|  | 302 | union | 
|  | 303 | { | 
|  | 304 | /* DBG_EXT_TYPE_CARD_TRACE */ | 
|  | 305 | struct | 
|  | 306 | { | 
|  | 307 | void ( * MaskChangedNotify) (void *pContext); | 
|  | 308 | unsigned long   ModuleTxtMask; | 
|  | 309 | unsigned long   DebugLevel; | 
|  | 310 | unsigned long   B_ChannelMask; | 
|  | 311 | unsigned long   LogBufferSize; | 
|  | 312 | } CardTrace; | 
|  | 313 | }Data; | 
|  | 314 | } _DbgExtendedInfo_; | 
|  | 315 | #ifndef DIVA_NO_DEBUGLIB | 
|  | 316 | /* ------------------------------------------------------------- | 
|  | 317 | Function used for xlog-style debug | 
|  | 318 | ------------------------------------------------------------- */ | 
|  | 319 | #define XDI_USE_XLOG 1 | 
|  | 320 | void  xdi_dbg_xlog (char* x, ...); | 
|  | 321 | #endif /* DIVA_NO_DEBUGLIB */ | 
|  | 322 | #endif /* __DEBUGLIB_H__ */ |