1/*
2 * dspbridge/mpu_api/inc/dbg.h
3 *
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5 *
6 * Copyright (C) 2007 Texas Instruments, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published
10 * by the Free Software Foundation version 2.1 of the License.
11 *
12 * This program is distributed .as is. WITHOUT ANY WARRANTY of any kind,
13 * whether express or implied; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 */
17
18
19/*
20 *  ======== dbg.h ========
21 *  Purpose:
22 *      Provide debugging services for 'Bridge Mini Drivers.
23 *
24 *  Public Functions:
25 *      DBG_Exit
26 *      DBG_Init
27 *      DBG_Printf
28 *      DBG_Trace
29 *
30 *  Notes:
31 *      WMD's must not call DBG_Init or DBG_Exit.
32 *
33 *! Revision History:
34 *! ================
35 *! 03-Feb-2000 rr: DBG Levels redefined.
36 *! 29-Oct-1999 kc: Cleaned up for code review.
37 *! 10-Oct-1997 cr: Added DBG_Printf service.
38 *! 29-May-1996 gp: Removed WCD_ prefix.
39 *! 15-May-1996 gp: Created.
40 */
41
42#ifndef DBG_
43#define DBG_
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#include <dspapi.h>
50
51/* Levels of trace debug messages: */
52#ifndef LINUX			/* No DEBUGZONE in Linux, DBG mask == GT mask */
53#define DBG_ENTER   (BYTE)(0x01 & DEBUGZONE(0))	/* Function entry point. */
54#define DBG_LEVEL1  (BYTE)(0x02 & DEBUGZONE(1))	/* Display debugging state/varibles */
55#define DBG_LEVEL2  (BYTE)(0x04 & DEBUGZONE(2))	/* Display debugging state/varibles */
56#define DBG_LEVEL3  (BYTE)(0x08 & DEBUGZONE(3))	/* Display debugging state/varibles */
57#define DBG_LEVEL4  (BYTE)(0x10 & DEBUGZONE(4))	/* Display debugging state/varibles */
58#define DBG_LEVEL5  (BYTE)(0x20 & DEBUGZONE(5))	/* Module Init, Exit */
59#define DBG_LEVEL6  (BYTE)(0x40 & DEBUGZONE(6))	/* Warn SERVICES Failures */
60#define DBG_LEVEL7  (BYTE)(0x80 & DEBUGZONE(7))	/* Warn Critical Errors */
61#else
62#define DBG_ENTER   (BYTE)(0x01)	/* Function entry point. */
63#define DBG_LEVEL1  (BYTE)(0x02)	/* Display debugging state/varibles */
64#define DBG_LEVEL2  (BYTE)(0x04)	/* Display debugging state/varibles */
65#define DBG_LEVEL3  (BYTE)(0x08)	/* Display debugging state/varibles */
66#define DBG_LEVEL4  (BYTE)(0x10)	/* Display debugging state/varibles */
67#define DBG_LEVEL5  (BYTE)(0x20)	/* Module Init, Exit */
68#define DBG_LEVEL6  (BYTE)(0x40)	/* Warn SERVICES Failures */
69#define DBG_LEVEL7  (BYTE)(0x80)	/* Warn Critical Errors */
70#endif
71
72#if ((defined DEBUG) || (defined DDSP_DEBUG_PRODUCT)) && GT_TRACE
73
74/*
75 *  ======== DBG_Exit ========
76 *  Purpose:
77 *      Discontinue usage of module; free resources when reference count
78 *      reaches 0.
79 *  Parameters:
80 *  Returns:
81 *  Requires:
82 *      DBG initialized.
83 *  Ensures:
84 *      Resources used by module are freed when cRef reaches zero.
85 */
86	extern VOID DBG_Exit();
87
88/*
89 *  ======== DBG_Init ========
90 *  Purpose:
91 *      Initializes private state of DBG module.
92 *  Parameters:
93 *  Returns:
94 *      TRUE if initialized; FALSE if error occured.
95 *  Requires:
96 *  Ensures:
97 */
98	extern bool DBG_Init();
99
100#ifndef LINUX
101/*
102 *  ======== DBG_Printf ========
103 *  Purpose:
104 *      Output a formatted string to the debugger.
105 *  Parameters:
106 *      pstrFormat: sprintf-style format string.
107 *      ...:        Arguments for format string.
108 *  Returns:
109 *      DSP_SOK:    Success, or trace level masked.
110 *      DSP_EFAIL:  On Error.
111 *  Requires:
112 *      DBG initialized.
113 *  Ensures:
114 */
115	extern DSP_STATUS DBG_Printf(IN PSTR pstrFormat, ...);
116#endif				// LINUX
117
118/*
119 *  ======== DBG_Trace ========
120 *  Purpose:
121 *      Output a trace message to the debugger, if the given trace level
122 *      is unmasked.
123 *  Parameters:
124 *      bLevel:         Trace level.
125 *      pstrFormat:     sprintf-style format string.
126 *      ...:            Arguments for format string.
127 *  Returns:
128 *      DSP_SOK:        Success, or trace level masked.
129 *      DSP_EFAIL:      On Error.
130 *  Requires:
131 *      DBG initialized.
132 *  Ensures:
133 *      Debug message is printed to debugger output window, if trace level
134 *      is unmasked.
135 */
136	extern DSP_STATUS DBG_Trace(IN BYTE bLevel, IN PSTR pstrFormat, ...);
137#else
138
139#define DBG_Exit()
140#define DBG_Init() TRUE
141#define DBG_Trace(bLevel, pstrFormat, args...)
142
143#endif				// ((defined DEBUG) || (defined DDSP_DEBUG_PRODUCT)) && GT_TRACE
144
145#ifdef __cplusplus
146}
147#endif
148#endif				/* DBG_ */
149