source: cmedia/trunk/Drv16/log.hpp@ 354

Last change on this file since 354 was 354, checked in by stevenhl, 17 years ago

Import untested baseline cmedia sources, work products and binaries
Binaries and work products should be deleted from repository.
once new builds are verified to work.

File size: 5.0 KB
Line 
1/* SCCSID = src/dev/mme/tropez/log.hpp, tropez, c.basedd 97/07/17 */
2/****************************************************************************
3 * *
4 * Copyright (c) IBM Corporation 1994 - 1997. *
5 * *
6 * The following IBM OS/2 source code is provided to you solely for the *
7 * the purpose of assisting you in your development of OS/2 device drivers. *
8 * You may use this code in accordance with the IBM License Agreement *
9 * provided in the IBM Device Driver Source Kit for OS/2. *
10 * *
11 ****************************************************************************/
12/**@internal src/dev/mme/tropez/log.hpp, tropez, c.basedd
13 * LOG, BINARYLOG, PERFLOG definitions.
14 * @version 1.6
15 * @context
16 * Unless otherwise noted, all interfaces are Ring-0, 16-bit, kernel stack.
17 * @notes
18 * ### More is coming in this area.
19 * @history
20 */
21
22#ifndef LOG_INCLUDED
23#define LOG_INCLUDED
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28#ifndef OS2_INCLUDED
29#define INCL_NOPMAPI
30#define INCL_DOSMISC
31#include <os2.h>
32#endif // OS2_INCLUDED
33#ifdef __cplusplus
34}
35#endif
36
37typedef unsigned short WORD;
38typedef unsigned long DWORD;
39
40// This structure is used to walk the parameters on the stack.
41typedef union {
42 void far *VoidPtr;
43 BYTE far *BytePtr;
44 WORD far *WordPtr;
45 DWORD far *LongPtr;
46 DWORD far *StringPtr; //### Why did this break when made
47 //### into a 'char far *?
48} STACK_ADR, FAR *PSTACK_ADR;
49
50
51// Maximum length of a message.
52const int MAX_MsgLen = 255;
53
54// Enumerate the places where logging messages can be saved.
55enum _MessageSink { _Display, _SerialLine, _ErrorLog, _TraceLog };
56const int _nMsgSinks = _TraceLog + 1;
57
58class LOG {
59public:
60 //--- Data.
61
62 // This vector indicates whether or not the messages should be streamed
63 // to a particular message sink. Initialized to all TRUE.
64 BOOL bMsgSink[_nMsgSinks];
65
66 //--- Public methods.
67
68 // Create a log.
69 LOG( USHORT DosTraceLogMajor, PSZ* apszMsgText );
70
71 // Log an event without data.
72 virtual void vTrace( USHORT errNum );
73
74 // Log an event with data.
75 virtual void vLog( USHORT errNum, ... );
76
77protected:
78
79 //--- Private and protected data.
80
81 // This is the major code (must be in range of 240 to 255) under which
82 // messages will be saved in the System Trace log. Messages can be retrieved
83 // using the OS/2 TRACEFMT utility.
84 const USHORT _DosTraceMajorCode;
85
86 // This vbls is a pointer to an array of NLV messages. An array of messages
87 // is assoicated with this LOG object when the object is created.
88 PSZ* _apszMsgText;
89
90 // Private scratch area. We build up the log entries in this string.
91 UCHAR _dd_BuildString[ MAX_MsgLen ];
92
93private:
94
95 // Keep track of whether we're executing at Ring3 or 0.
96 BOOL _bInRing3;
97
98 // Comm port (COM1: or COM2:) to send messages out of (used only if
99 // the Serial line is selected as a message sink.
100 USHORT _ComPort;
101
102 //--- Private member functions
103
104 // Binary to Ascii conversion routines.
105 PSZ _DecWordToASCII( PSZ StrPtr, WORD wDecVal, WORD Option );
106 PSZ _DecLongToASCII( PSZ StrPtr, DWORD lDecVal,WORD Option );
107 PSZ _HexWordToASCII( PSZ StrPtr, WORD wHexVal, WORD Option );
108 PSZ _HexLongToASCII( PSZ StrPtr, DWORD wHexVal, WORD Option );
109
110 // Send a character out the COM port.
111 void _CharOut( char );
112
113 // Save the message in one or more destinations.
114 void _ddputstring ( USHORT iMsgNum, PSZ St);
115
116 // Formatting routine - converts binary->ASCII & merges with PII.
117 USHORT _ddsprintf ( PSZ pszOutString, PSZ pszFmtString, STACK_ADR Parm );
118
119}; // class LOG
120
121
122class BINARYLOG : public LOG {
123public:
124
125 // Create a log.
126 BINARYLOG( USHORT DosTraceLogMajor, PSZ* apszMsgText );
127
128 // Log a trace point.
129 virtual void vTrace( USHORT eventNum );
130
131 // Log an event with data.
132 virtual void vLog( USHORT eventNum, ... );
133
134private:
135
136 // Formatting routine - converts binary->ASCII & merges with PII.
137 USHORT _ddsprintf ( PSZ pszOutString, PSZ pszFmtString, STACK_ADR Parm );
138
139}; // class BINARYLOG
140
141
142class PERFLOG : public LOG {
143public:
144
145 // Create a log.
146 PERFLOG( USHORT DosTraceLogMajor, PSZ* apszMsgText );
147
148 // Record current RDTSC cycle count (from Intel processor) into system Trace log.
149 virtual void vTrace( USHORT eventNum );
150
151}; // class PERFLOG
152
153
154extern LOG* pStatus; // Status log.
155extern LOG* pError; // Error log.
156extern LOG* pSoftError; // Error log.
157extern BINARYLOG* pTrace; // Trace log.
158extern PERFLOG* pPerfLog; // Performance trace log.
159
160#endif // LOG_INCLUDED
161
Note: See TracBrowser for help on using the repository browser.