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
27#include "debuglib.h"
28
29#ifdef DIVA_NO_DEBUGLIB
30static DIVA_DI_PRINTF dprintf;
31#else
32
33_DbgHandle_ myDriverDebugHandle = { 0 , DBG_HANDLE_VERSION };
34DIVA_DI_PRINTF dprintf = no_printf;
35
36#define DBG_FUNC(name) \
37 void \
38 myDbgPrint_##name(char *format, ...) \
39 { va_list ap; \
40 if (myDriverDebugHandle.dbg_prt) \
41 { va_start(ap, format); \
42 (myDriverDebugHandle.dbg_prt) \
43 (myDriverDebugHandle.id, DLI_##name, format, ap); \
44 va_end(ap); \
45 } }
46DBG_FUNC(LOG)
47DBG_FUNC(FTL)
48DBG_FUNC(ERR)
49DBG_FUNC(TRC)
50DBG_FUNC(MXLOG)
51DBG_FUNC(FTL_MXLOG)
52void
53myDbgPrint_EVL(long msgID, ...)
54{ va_list ap;
55 if (myDriverDebugHandle.dbg_ev)
56 { va_start(ap, msgID);
57 (myDriverDebugHandle.dbg_ev)
58 (myDriverDebugHandle.id, (unsigned long)msgID, ap);
59 va_end(ap);
60 } }
61DBG_FUNC(REG)
62DBG_FUNC(MEM)
63DBG_FUNC(SPL)
64DBG_FUNC(IRP)
65DBG_FUNC(TIM)
66DBG_FUNC(BLK)
67DBG_FUNC(TAPI)
68DBG_FUNC(NDIS)
69DBG_FUNC(CONN)
70DBG_FUNC(STAT)
71DBG_FUNC(SEND)
72DBG_FUNC(RECV)
73DBG_FUNC(PRV0)
74DBG_FUNC(PRV1)
75DBG_FUNC(PRV2)
76DBG_FUNC(PRV3)
77
78int
79DbgRegister(char *drvName, char *drvTag, unsigned long dbgMask)
80{
81 int len;
82
83
84
85 DbgDeregister();
86
87
88
89 myDriverDebugHandle.Version = DBG_HANDLE_VERSION;
90 myDriverDebugHandle.id = -1;
91 myDriverDebugHandle.dbgMask = dbgMask | (DL_EVL | DL_FTL | DL_LOG);
92 len = strlen(drvName);
93 memcpy(myDriverDebugHandle.drvName, drvName,
94 (len < sizeof(myDriverDebugHandle.drvName)) ?
95 len : sizeof(myDriverDebugHandle.drvName) - 1);
96 len = strlen(drvTag);
97 memcpy(myDriverDebugHandle.drvTag, drvTag,
98 (len < sizeof(myDriverDebugHandle.drvTag)) ?
99 len : sizeof(myDriverDebugHandle.drvTag) - 1);
100
101
102
103 dprintf("\000\377", &myDriverDebugHandle);
104 if (myDriverDebugHandle.dbg_prt)
105 {
106 return (1);
107 }
108
109
110
111 if (myDriverDebugHandle.dbg_end != NULL
112
113 && (myDriverDebugHandle.regTime.LowPart ||
114 myDriverDebugHandle.regTime.HighPart))
115
116 {
117 dprintf("%s: Cannot log to old maint driver !", drvName);
118 myDriverDebugHandle.dbg_end =
119 ((_OldDbgHandle_ *)&myDriverDebugHandle)->dbg_end;
120 DbgDeregister();
121 }
122 return (0);
123}
124
125void
126DbgSetLevel(unsigned long dbgMask)
127{
128 myDriverDebugHandle.dbgMask = dbgMask | (DL_EVL | DL_FTL | DL_LOG);
129}
130
131void
132DbgDeregister(void)
133{
134 if (myDriverDebugHandle.dbg_end)
135 {
136 (myDriverDebugHandle.dbg_end)(&myDriverDebugHandle);
137 }
138 memset(&myDriverDebugHandle, 0, sizeof(myDriverDebugHandle));
139}
140void xdi_dbg_xlog(char *x, ...) {
141 va_list ap;
142 va_start(ap, x);
143 if (myDriverDebugHandle.dbg_end &&
144 (myDriverDebugHandle.dbg_irq || myDriverDebugHandle.dbg_old) &&
145 (myDriverDebugHandle.dbgMask & DL_STAT)) {
146 if (myDriverDebugHandle.dbg_irq) {
147 (*(myDriverDebugHandle.dbg_irq))(myDriverDebugHandle.id,
148 (x[0] != 0) ? DLI_TRC : DLI_XLOG, x, ap);
149 } else {
150 (*(myDriverDebugHandle.dbg_old))(myDriverDebugHandle.id, x, ap);
151 }
152 }
153 va_end(ap);
154}
155
156#endif
157