4 Copyright (c) Eicon Networks, 2002.
6 This source file is supplied for the use with
7 Eicon Networks range of DIVA Server Adapters.
9 Eicon File Revision : 2.1
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)
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.
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.
29 #ifdef DIVA_NO_DEBUGLIB
30 static DIVA_DI_PRINTF dprintf;
31 #else /* DIVA_NO_DEBUGLIB */
33 _DbgHandle_ myDriverDebugHandle = { 0 /*!Registered*/, DBG_HANDLE_VERSION };
34 DIVA_DI_PRINTF dprintf = no_printf;
35 /*****************************************************************************/
36 #define DBG_FUNC(name) \
38 myDbgPrint_##name(char *format, ...) \
40 if (myDriverDebugHandle.dbg_prt) \
41 { va_start(ap, format); \
42 (myDriverDebugHandle.dbg_prt) \
43 (myDriverDebugHandle.id, DLI_##name, format, ap); \
53 myDbgPrint_EVL(long msgID, ...)
55 if (myDriverDebugHandle.dbg_ev)
56 { va_start(ap, msgID);
57 (myDriverDebugHandle.dbg_ev)
58 (myDriverDebugHandle.id, (unsigned long)msgID, ap);
77 /*****************************************************************************/
79 DbgRegister(char *drvName, char *drvTag, unsigned long dbgMask)
83 * deregister (if already registered) and zero out myDriverDebugHandle
87 * initialize the debug handle
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);
97 memcpy(myDriverDebugHandle.drvTag, drvTag,
98 (len < sizeof(myDriverDebugHandle.drvTag)) ?
99 len : sizeof(myDriverDebugHandle.drvTag) - 1);
101 * Try to register debugging via old (and only) interface
103 dprintf("\000\377", &myDriverDebugHandle);
104 if (myDriverDebugHandle.dbg_prt)
109 * Check if we registered with an old maint driver (see debuglib.h)
111 if (myDriverDebugHandle.dbg_end != NULL
112 /* location of 'dbg_prt' in _OldDbgHandle_ struct */
113 && (myDriverDebugHandle.regTime.LowPart ||
114 myDriverDebugHandle.regTime.HighPart))
115 /* same location as in _OldDbgHandle_ struct */
117 dprintf("%s: Cannot log to old maint driver !", drvName);
118 myDriverDebugHandle.dbg_end =
119 ((_OldDbgHandle_ *)&myDriverDebugHandle)->dbg_end;
124 /*****************************************************************************/
126 DbgSetLevel(unsigned long dbgMask)
128 myDriverDebugHandle.dbgMask = dbgMask | (DL_EVL | DL_FTL | DL_LOG);
130 /*****************************************************************************/
134 if (myDriverDebugHandle.dbg_end)
136 (myDriverDebugHandle.dbg_end)(&myDriverDebugHandle);
138 memset(&myDriverDebugHandle, 0, sizeof(myDriverDebugHandle));
140 void xdi_dbg_xlog(char *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);
150 (*(myDriverDebugHandle.dbg_old))(myDriverDebugHandle.id, x, ap);
155 /*****************************************************************************/
156 #endif /* DIVA_NO_DEBUGLIB */