4c8f8e300f64a5e312f9f2e84f7fc332bab10df0
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
, ...)
234 int *dataptr
= (int *) &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 vsprintf(Buffer
, format
, (PVOID
)(++dataptr
));
254 DebugPrintChar(*ptr
++);
258 VOID
DebugPrint1(char *format
, ...)
260 int *dataptr
= (int *) &format
;
264 vsprintf(Buffer
, format
, (PVOID
)(++dataptr
));
267 DebugPrintChar(*ptr
++);
271 VOID
DebugDumpBuffer(ULONG Mask
, PVOID Buffer
, ULONG Length
)
273 PUCHAR BufPtr
= (PUCHAR
)Buffer
;
277 // Mask out unwanted debug messages
278 if (!(Mask
& DebugPrintMask
))
283 DebugStartOfLine
= FALSE
; // We don't want line headers
284 DebugPrint(Mask
, "Dumping buffer at 0x%x with length of %d bytes:\n", Buffer
, Length
);
286 for (Idx
=0; Idx
<Length
; )
288 DebugStartOfLine
= FALSE
; // We don't want line headers
292 DebugPrint(Mask
, "000%x:\t", Idx
);
294 else if (Idx
< 0x0100)
296 DebugPrint(Mask
, "00%x:\t", Idx
);
298 else if (Idx
< 0x1000)
300 DebugPrint(Mask
, "0%x:\t", Idx
);
304 DebugPrint(Mask
, "%x:\t", Idx
);
307 for (Idx2
=0; Idx2
<16; Idx2
++,Idx
++)
309 if (BufPtr
[Idx
] < 0x10)
311 DebugPrint(Mask
, "0");
313 DebugPrint(Mask
, "%x", BufPtr
[Idx
]);
317 DebugPrint(Mask
, "-");
321 DebugPrint(Mask
, " ");
326 DebugPrint(Mask
, " ");
328 for (Idx2
=0; Idx2
<16; Idx2
++,Idx
++)
330 if ((BufPtr
[Idx
] > 20) && (BufPtr
[Idx
] < 0x80))
332 DebugPrint(Mask
, "%c", BufPtr
[Idx
]);
336 DebugPrint(Mask
, ".");
340 DebugPrint(Mask
, "\n");
344 #endif // defined DEBUG