d4a491a0f91582a6fb958d4033992b85350624e4
3 * Copyright (C) 1998-2002 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.
28 //#define DEBUG_INIFILE
29 //#define DEBUG_REACTOS
30 //#define DEBUG_CUSTOM
34 ULONG DebugPrintMask
= DPRINT_WARNING
| DPRINT_MEMORY
| DPRINT_FILESYSTEM
|
35 DPRINT_UI
| DPRINT_DISK
| DPRINT_CACHE
| DPRINT_REACTOS
|
40 ULONG DebugPrintMask
= DPRINT_INIFILE
;
44 ULONG DebugPrintMask
= DPRINT_REACTOS
| DPRINT_REGISTRY
;
48 ULONG DebugPrintMask
= 0;
52 ULONG DebugPrintMask
= 0;
64 #define BOCHS_OUTPUT_PORT 0xe9
66 //ULONG DebugPort = RS232;
67 //ULONG DebugPort = SCREEN;
68 ULONG DebugPort
= BOCHS
;
70 //ULONG BaudRate = 19200;
71 ULONG BaudRate
= 115200;
73 BOOL DebugStartOfLine
= TRUE
;
77 if (DebugPort
== RS232
)
79 Rs232PortInitialize(ComPort
, BaudRate
);
83 VOID
DebugPrintChar(UCHAR Character
)
85 if (Character
== '\n')
87 DebugStartOfLine
= TRUE
;
90 if (DebugPort
== RS232
)
92 if (Character
== '\n')
94 Rs232PortPutByte('\r');
96 Rs232PortPutByte(Character
);
98 else if (DebugPort
== BOCHS
)
100 WRITE_PORT_UCHAR((PUCHAR
)BOCHS_OUTPUT_PORT
, Character
);
108 VOID
DebugPrintHeader(ULONG Mask
)
137 case DPRINT_FILESYSTEM
:
182 case DPRINT_REGISTRY
:
228 VOID
DebugPrint(ULONG Mask
, char *format
, ...)
230 int *dataptr
= (int *) &format
;
231 char c
, *ptr
, str
[16];
233 // Mask out unwanted debug messages
234 if (!(Mask
& DebugPrintMask
))
239 // Print the header if we have started a new line
240 if (DebugStartOfLine
)
242 DebugPrintHeader(Mask
);
243 DebugStartOfLine
= FALSE
;
248 while ((c
= *(format
++)))
256 switch (c
= *(format
++))
258 case 'd': case 'u': case 'x':
260 *convert_to_ascii(str
, c
, *((unsigned long *) dataptr
++)) = 0;
266 DebugPrintChar(*(ptr
++));
272 DebugPrintChar((*(dataptr
++))&0xff);
277 ptr
= (char *)(*(dataptr
++));
279 while ((c
= *(ptr
++)))
289 if (DebugPort
== SCREEN
)
296 VOID
DebugDumpBuffer(ULONG Mask
, PVOID Buffer
, ULONG Length
)
298 PUCHAR BufPtr
= (PUCHAR
)Buffer
;
302 // Mask out unwanted debug messages
303 if (!(Mask
& DebugPrintMask
))
308 DebugStartOfLine
= FALSE
; // We don't want line headers
309 DebugPrint(Mask
, "Dumping buffer at 0x%x with length of %d bytes:\n", Buffer
, Length
);
311 for (Idx
=0; Idx
<Length
; )
313 DebugStartOfLine
= FALSE
; // We don't want line headers
317 DebugPrint(Mask
, "000%x:\t", Idx
);
319 else if (Idx
< 0x0100)
321 DebugPrint(Mask
, "00%x:\t", Idx
);
323 else if (Idx
< 0x1000)
325 DebugPrint(Mask
, "0%x:\t", Idx
);
329 DebugPrint(Mask
, "%x:\t", Idx
);
332 for (Idx2
=0; Idx2
<16; Idx2
++,Idx
++)
334 if (BufPtr
[Idx
] < 0x10)
336 DebugPrint(Mask
, "0");
338 DebugPrint(Mask
, "%x", BufPtr
[Idx
]);
342 DebugPrint(Mask
, "-");
346 DebugPrint(Mask
, " ");
351 DebugPrint(Mask
, " ");
353 for (Idx2
=0; Idx2
<16; Idx2
++,Idx
++)
355 if ((BufPtr
[Idx
] > 20) && (BufPtr
[Idx
] < 0x80))
357 DebugPrint(Mask
, "%c", BufPtr
[Idx
]);
361 DebugPrint(Mask
, ".");
365 DebugPrint(Mask
, "\n");
369 #endif // defined DEBUG