89e27152bebe774d4880e22f4c5498cf72e38b9a
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 //#define DEBUG_INIFILE
28 //#define DEBUG_REACTOS
29 //#define DEBUG_CUSTOM
32 #if defined (DEBUG_ALL)
33 ULONG DebugPrintMask
= DPRINT_WARNING
| DPRINT_MEMORY
| DPRINT_FILESYSTEM
|
34 DPRINT_UI
| DPRINT_DISK
| DPRINT_CACHE
| DPRINT_REACTOS
|
35 DPRINT_LINUX
| DPRINT_HWDETECT
;
36 #elif defined (DEBUG_INIFILE)
37 ULONG DebugPrintMask
= DPRINT_INIFILE
;
38 #elif defined (DEBUG_REACTOS)
39 ULONG DebugPrintMask
= DPRINT_REACTOS
| DPRINT_REGISTRY
;
40 #elif defined (DEBUG_CUSTOM)
41 ULONG DebugPrintMask
= DPRINT_WARNING
|DPRINT_FILESYSTEM
|DPRINT_MEMORY
|DPRINT_LINUX
;
42 #else //#elif defined (DEBUG_NONE)
43 ULONG DebugPrintMask
= 0;
55 #define BOCHS_OUTPUT_PORT 0xe9
57 ULONG DebugPort
= RS232
;
58 //ULONG DebugPort = SCREEN;
59 //ULONG DebugPort = BOCHS;
60 //ULONG DebugPort = SCREEN|BOCHS;
62 //ULONG BaudRate = 19200;
63 ULONG BaudRate
= 115200;
65 BOOL DebugStartOfLine
= TRUE
;
69 if (DebugPort
& RS232
)
71 Rs232PortInitialize(ComPort
, BaudRate
);
75 VOID
DebugPrintChar(UCHAR Character
)
77 if (Character
== '\n')
79 DebugStartOfLine
= TRUE
;
82 if (DebugPort
& RS232
)
84 if (Character
== '\n')
86 Rs232PortPutByte('\r');
88 Rs232PortPutByte(Character
);
90 if (DebugPort
& BOCHS
)
92 WRITE_PORT_UCHAR((PUCHAR
)BOCHS_OUTPUT_PORT
, Character
);
94 if (DebugPort
& SCREEN
)
96 MachConsPutChar(Character
);
100 VOID
DebugPrintHeader(ULONG Mask
)
129 case DPRINT_FILESYSTEM
:
174 case DPRINT_REGISTRY
:
206 case DPRINT_HWDETECT
:
232 VOID
DebugPrint(ULONG Mask
, char *format
, ...)
238 // Mask out unwanted debug messages
239 if (!(Mask
& DebugPrintMask
))
244 // Print the header if we have started a new line
245 if (DebugStartOfLine
)
247 DebugPrintHeader(Mask
);
248 DebugStartOfLine
= FALSE
;
251 va_start(ap
, format
);
252 vsprintf(Buffer
, format
, ap
);
256 DebugPrintChar(*ptr
++);
260 VOID
DebugPrint1(char *format
, ...)
266 va_start(ap
, format
);
267 vsprintf(Buffer
, format
, ap
);
271 DebugPrintChar(*ptr
++);
275 VOID
DebugDumpBuffer(ULONG Mask
, PVOID Buffer
, ULONG Length
)
277 PUCHAR BufPtr
= (PUCHAR
)Buffer
;
281 // Mask out unwanted debug messages
282 if (!(Mask
& DebugPrintMask
))
287 DebugStartOfLine
= FALSE
; // We don't want line headers
288 DebugPrint(Mask
, "Dumping buffer at 0x%x with length of %d bytes:\n", Buffer
, Length
);
290 for (Idx
=0; Idx
<Length
; )
292 DebugStartOfLine
= FALSE
; // We don't want line headers
296 DebugPrint(Mask
, "000%x:\t", Idx
);
298 else if (Idx
< 0x0100)
300 DebugPrint(Mask
, "00%x:\t", Idx
);
302 else if (Idx
< 0x1000)
304 DebugPrint(Mask
, "0%x:\t", Idx
);
308 DebugPrint(Mask
, "%x:\t", Idx
);
311 for (Idx2
=0; Idx2
<16; Idx2
++,Idx
++)
313 if (BufPtr
[Idx
] < 0x10)
315 DebugPrint(Mask
, "0");
317 DebugPrint(Mask
, "%x", BufPtr
[Idx
]);
321 DebugPrint(Mask
, "-");
325 DebugPrint(Mask
, " ");
330 DebugPrint(Mask
, " ");
332 for (Idx2
=0; Idx2
<16; Idx2
++,Idx
++)
334 if ((BufPtr
[Idx
] > 20) && (BufPtr
[Idx
] < 0x80))
336 DebugPrint(Mask
, "%c", BufPtr
[Idx
]);
340 DebugPrint(Mask
, ".");
344 DebugPrint(Mask
, "\n");
348 #endif // defined DEBUG