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.
27 //ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
28 // DPRINT_UI | DPRINT_DISK | DPRINT_CACHE;
29 ULONG DebugPrintMask
= DPRINT_WARNING
| DPRINT_MEMORY
| DPRINT_FILESYSTEM
|
30 DPRINT_UI
| DPRINT_DISK
;
31 //ULONG DebugPrintMask = DPRINT_CACHE;
42 #define BOCHS_OUTPUT_PORT 0xe9
44 ULONG DebugPort
= RS232
;
45 //ULONG DebugPort = SCREEN;
46 //ULONG DebugPort = BOCHS;
48 //ULONG BaudRate = 19200;
49 ULONG BaudRate
= 115200;
51 BOOL DebugStartOfLine
= TRUE
;
55 if (DebugPort
== RS232
)
57 Rs232PortInitialize(ComPort
, BaudRate
);
61 VOID
DebugPrintChar(UCHAR Character
)
63 if (Character
== '\n')
65 DebugStartOfLine
= TRUE
;
68 if (DebugPort
== RS232
)
70 if (Character
== '\n')
72 Rs232PortPutByte('\r');
74 Rs232PortPutByte(Character
);
76 else if (DebugPort
== BOCHS
)
78 WRITE_PORT_UCHAR((PUCHAR
)BOCHS_OUTPUT_PORT
, Character
);
86 VOID
DebugPrintHeader(ULONG Mask
)
111 case DPRINT_FILESYSTEM
:
170 VOID
DebugPrint(ULONG Mask
, char *format
, ...)
172 int *dataptr
= (int *) &format
;
173 char c
, *ptr
, str
[16];
175 // Mask out unwanted debug messages
176 if (!(Mask
& DebugPrintMask
))
181 // Print the header if we have started a new line
182 if (DebugStartOfLine
)
184 DebugPrintHeader(Mask
);
185 DebugStartOfLine
= FALSE
;
190 while ((c
= *(format
++)))
198 switch (c
= *(format
++))
200 case 'd': case 'u': case 'x':
202 *convert_to_ascii(str
, c
, *((unsigned long *) dataptr
++)) = 0;
208 DebugPrintChar(*(ptr
++));
214 DebugPrintChar((*(dataptr
++))&0xff);
219 ptr
= (char *)(*(dataptr
++));
221 while ((c
= *(ptr
++)))
231 if (DebugPort
== SCREEN
)
238 #endif // defined DEBUG