Mdebug.h
9.22 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* Mdebug.h
*
* Project:
* --------
* META
*
* Description:
* ------------
* Debug log module for META project.
*
* Author:
* -------
* Amos Hsu (mtk00539)
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Revision: 1.9 $
* $Modtime: Jan 12 2006 15:51:06 $
* $Log: //mtkvs01/vmdata/meta_dll/archives/maui/META_DLL/Mdebug.h-arc $
*
* Feb 26 2006 mtk00539
* [STP100000625] FlashTool v2.7.1016
*
*
* Rev 1.9 Jan 14 2006 00:29:52 mtk00539
* Enhancements:
* 1. [BROM_DLL] Dump debug log in BootROM write cmd.
* Resolution for 159: [FlashTool v2.7.1015]
*
* Rev 1.8 Oct 21 2003 17:08:48 mtk00539
* add debug prefix
* Resolution for 32: [META_DLL v3.3.1001][New] See the details below.
*
* Rev 1.7 Oct 18 2003 13:57:06 mtk00539
* Add debug level
* Resolution for 31: [BootRom v2.1.1002][BUG FIX] Fix DA checksum error on Windows ME and 2000.
*
* Rev 1.6 Sep 02 2003 14:39:24 mtk00539
* 1. Fix m_bSystemTrace bug in operator ()
* 2. Modify MTRACE_ComposeDumpBuf() interface from unsigned char * to char *
* Resolution for 26: [META_DLL v3.1.1001][Add Feature] See the reasons below.
*
* Rev 1.5 Aug 06 2003 22:16:52 mtk00539
* 1. add new class MetaTrace_Handle_Sentry and MetaTrace_Log_Sentry.
* 2. add new api MTRACE_IsDumpFileOpen().
* Resolution for 24: [BootRom v2.0.1008][Add Features] Support MT6218 Cannon, Enhance debug log.
*
* Rev 1.4 Jul 25 2003 15:50:28 mtk00539
* Reason:
* 1. SA reports read(10sec)/write(3sec) timeouts are too long. Because DA_cmd::WriteData() and DA_cmd::ReadData() will re-try one time, so the actual timeouts are read(10x2sec)/write(3x2sec). So I decide to reduce timeouts to read(5sec)/write(1.5sec).
*
* 2. Add specific debug log at the end of FlashDownload(), FlashReadback() and FlashFormat(). In this way SA can query whether if the function successfully executed by this signature.
*
* 3. Export debug log clear function, let users clear debug log whenever they want.
* Resolution for 17: [BootRom v2.0.1006][Add Features] shorten read/write timeout and export debug log clear function.
*
* Rev 1.3 Jun 30 2003 20:39:02 mtk00539
* enable runtime trace
* Resolution for 12: [BootRom v2.2.1001][New Version] Split flashtool function into brom.dll
*
* Rev 1.2 Jun 30 2003 19:46:08 mtk00539
* Add include <stdio.h>
* Resolution for 12: [BootRom v2.2.1001][New Version] Split flashtool function into brom.dll
*
* Rev 1.1 Apr 01 2003 09:39:46 mtk00539
* 1. enlarge buffer
* 2. fix BUG: _snprintf() buffer length count error.
* 3. display both HEX and ASCII value in MTRACE_ComposeDumpBuf()
* 4. remove MTRACE_DumpFileRedirect() and MTRACE_DumpFileGetFP().
* 5. add MTRACE_DumpToStdio()
* 6. add CRITICAL_SECTION to protect buffer and handle.
* Resolution for 3: [META_DLL v2.0][AddFeature] Add new features for META_DLL v2.0
*
* Rev 1.0 Feb 25 2003 13:24:20 admin
* Initial revision.
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#ifndef _META_TRACE_H_
#define _META_TRACE_H_
#include <stdio.h>
#define MDEBUG_RUNTIME_TRACE 1
//--------------------------------------------------------------------------//
// The definition of MetaTrace data structure //
//--------------------------------------------------------------------------//
struct MetaTraceHandle;
typedef struct MetaTraceHandle * hMTRACE;
typedef const struct MetaTraceHandle * hMTRACE_const;
//--------------------------------------------------------------------------//
// The definition of trace level //
//--------------------------------------------------------------------------//
#define MTRACE_LEVEL_LOG_0 0
#define MTRACE_LEVEL_LOG_1 1
#define MTRACE_LEVEL_LOG_2 2
#define MTRACE_LEVEL_SYSTEM 200
#define MTRACE_LEVEL_WARNING 210
#define MTRACE_LEVEL_TOP 255
#define MTRACE_LEVEL_ERROR MTRACE_LEVEL_TOP
#define LIBEXPORT __declspec(dllexport)
//--------------------------------------------------------------------------//
// MetaTrace class //
//--------------------------------------------------------------------------//
class LIBEXPORT MetaTrace
{
private:
const char *m_file;
int m_line;
unsigned char m_level;
const char *m_prefix;
public:
explicit MetaTrace( const char* file, int line, unsigned char level=MTRACE_LEVEL_LOG_0, const char *prefix="");
virtual ~MetaTrace();
void operator()( hMTRACE handle, const char* Format, ... );
};
//--------------------------------------------------------------------------//
// MetaTrace handle create/destroy sentry class //
//--------------------------------------------------------------------------//
class LIBEXPORT MetaTrace_Handle_Sentry {
public:
explicit MetaTrace_Handle_Sentry(hMTRACE &debug_handle, const char *ProcessName, bool bSystemTrace, bool bTraceEnable, unsigned char level=MTRACE_LEVEL_LOG_0, const char *DumpFile=NULL, const char *Mode="w");
~MetaTrace_Handle_Sentry();
private:
hMTRACE &m_debug;
};
//--------------------------------------------------------------------------//
// MetaTrace log sentry class //
//--------------------------------------------------------------------------//
class LIBEXPORT MetaTrace_Log_Sentry {
public:
explicit MetaTrace_Log_Sentry(hMTRACE &debug_handle, const char *begin_hint=NULL, const char *end_hint=NULL);
~MetaTrace_Log_Sentry();
private:
char m_begin_hint[256];
char m_end_hint[256];
hMTRACE &m_debug;
};
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------------//
// Meta Trace API //
//--------------------------------------------------------------------------//
LIBEXPORT extern hMTRACE MTRACE_Create(const char *ProcessName, bool bSystemTrace, bool bTraceEnable, unsigned char level);
LIBEXPORT extern int MTRACE_Destroy(hMTRACE *p_handle);
LIBEXPORT extern int MTRACE_ON(hMTRACE handle);
LIBEXPORT extern int MTRACE_OFF(hMTRACE handle);
LIBEXPORT extern bool MTRACE_IsTraceEnabled(hMTRACE handle);
LIBEXPORT extern int MTRACE_SetSysTrace(hMTRACE handle, bool bEnable);
LIBEXPORT extern int MTRACE_SetLevel(hMTRACE handle, unsigned char level);
LIBEXPORT extern int MTRACE_GetLevel(hMTRACE handle, unsigned char *p_level);
LIBEXPORT extern bool MTRACE_IsDumpFileOpen(hMTRACE handle);
LIBEXPORT extern int MTRACE_DumpToStdio(hMTRACE handle, FILE *std_io);
LIBEXPORT extern int MTRACE_DumpFileOpen(hMTRACE handle, const char *DumpFile, const char *mode);
LIBEXPORT extern int MTRACE_DumpFileClose(hMTRACE handle);
LIBEXPORT extern int MTRACE_DumpFileClear(hMTRACE handle);
LIBEXPORT extern char *MTRACE_ComposeDumpBuf(const char *buf_in, unsigned long buf_in_len);
//-----------------------------------------------------//
// Meta Trace API: MTRACE macro //
//-----------------------------------------------------//
#if defined(_DEBUG) || defined(MDEBUG_RUNTIME_TRACE)
#define MTRACE (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_LOG_0 ))
#define MTRACE_SYS (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_SYSTEM, " SYSTEM:" ))
#define MTRACE_WARN (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_WARNING, " WARNING:" ))
#define MTRACE_ERR (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_ERROR, " ERROR:" ))
#define MTRACE_LVL(level) (MetaTrace( __FILE__, __LINE__, level ))
#else
extern __inline void MTRACE_Empty( hMTRACE handle, const char* Format, ... ); // dummy trace function
#define MTRACE (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_LOG_0 ))
#define MTRACE_SYS (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_SYSTEM, " SYSTEM:" ))
#define MTRACE_WARN (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_WARNING, " WARNING:" ))
#define MTRACE_ERR (MetaTrace( __FILE__, __LINE__, MTRACE_LEVEL_ERROR, " ERROR:" ))
#define MTRACE_LVL(level) (MetaTrace( __FILE__, __LINE__, level ))
#endif
//-----------------------------------------------------//
// Meta Trace API: general functions //
//-----------------------------------------------------//
int __stdcall Eboot_GetDLLVer(unsigned int *major_ver, unsigned int *minor_ver, unsigned int *build_num, unsigned int *patch_num );
#ifdef __cplusplus
}
#endif
#endif