1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#if !defined(__DEBUGLIB_H__)
27#define __DEBUGLIB_H__
28#include <stdarg.h>
29
30
31
32#define DL_LOG 0x00000001
33#define DL_FTL 0x00000002
34#define DL_ERR 0x00000004
35#define DL_TRC 0x00000008
36#define DL_XLOG 0x00000010
37#define DL_MXLOG 0x00000020
38#define DL_FTL_MXLOG 0x00000021
39#define DL_EVL 0x00000080
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
52
53#define DL_REG 0x00000100
54#define DL_MEM 0x00000200
55#define DL_SPL 0x00000400
56#define DL_IRP 0x00000800
57#define DL_TIM 0x00001000
58#define DL_BLK 0x00002000
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
68
69#define DL_TAPI 0x00010000
70#define DL_NDIS 0x00020000
71#define DL_CONN 0x00040000
72#define DL_STAT 0x00080000
73#define DL_SEND 0x00100000
74#define DL_RECV 0x00200000
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
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
100
101
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
132
133
134
135#define DBG_DECL(func) extern void myDbgPrint_##func(char *, ...);
136DBG_DECL(LOG)
137DBG_DECL(FTL)
138DBG_DECL(ERR)
139DBG_DECL(TRC)
140DBG_DECL(MXLOG)
141DBG_DECL(FTL_MXLOG)
142extern void myDbgPrint_EVL(long, ...);
143DBG_DECL(REG)
144DBG_DECL(MEM)
145DBG_DECL(SPL)
146DBG_DECL(IRP)
147DBG_DECL(TIM)
148DBG_DECL(BLK)
149DBG_DECL(TAPI)
150DBG_DECL(NDIS)
151DBG_DECL(CONN)
152DBG_DECL(STAT)
153DBG_DECL(SEND)
154DBG_DECL(RECV)
155DBG_DECL(PRV0)
156DBG_DECL(PRV1)
157DBG_DECL(PRV2)
158DBG_DECL(PRV3)
159#ifdef _KERNEL_DBG_PRINT_
160
161
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
173
174#define DBG_TEST(func, args) \
175 { if ((myDriverDebugHandle.dbgMask) & (unsigned long)DL_##func) \
176 { myDbgPrint_##func args; \
177 } }
178#endif
179
180
181
182
183#define DBG_EVL_ID(args) \
184 { if ((myDriverDebugHandle.dbgMask) & (unsigned long)DL_EVL) \
185 { myDbgPrint_EVL args; \
186 } }
187
188#endif
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
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
221extern DIVA_DI_PRINTF dprintf;
222extern int DbgRegister(char *drvName, char *drvTag, unsigned long dbgMask);
223extern void DbgDeregister(void);
224extern void DbgSetLevel(unsigned long dbgMask);
225#endif
226
227
228
229
230
231typedef struct _DbgHandle_ *pDbgHandle;
232typedef void (*DbgEnd)(pDbgHandle);
233typedef void (*DbgLog)(unsigned short, int, char *, va_list);
234typedef void (*DbgOld)(unsigned short, char *, va_list);
235typedef void (*DbgEv)(unsigned short, unsigned long, va_list);
236typedef void (*DbgIrq)(unsigned short, int, char *, va_list);
237typedef struct _DbgHandle_
238{ char Registered;
239#define DBG_HANDLE_REG_NEW 0x01
240#define DBG_HANDLE_REG_OLD 0x7f
241 char Version;
242#define DBG_HANDLE_VERSION 1
243#define DBG_HANDLE_VER_EXT 2
244 short id;
245 struct _DbgHandle_ *next;
246 struct {
247 unsigned long LowPart;
248 long HighPart;
249 } regTime;
250 void *pIrp;
251 unsigned long dbgMask;
252 char drvName[128];
253 char drvTag[64];
254 DbgEnd dbg_end;
255 DbgLog dbg_prt;
256 DbgOld dbg_old;
257 DbgEv dbg_ev;
258 DbgIrq dbg_irq;
259 void *pReserved3;
260} _DbgHandle_;
261extern _DbgHandle_ myDriverDebugHandle;
262typedef 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298#define DBG_EXT_TYPE_CARD_TRACE 0x00000001
299typedef struct
300{
301 unsigned long ExtendedType;
302 union
303 {
304
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
318
319#define XDI_USE_XLOG 1
320void xdi_dbg_xlog(char *x, ...);
321#endif
322#endif
323