Improved csrss (doesn't crash any more)
[reactos.git] / reactos / ntoskrnl / kd / kdebug.c
1 /* $Id: kdebug.c,v 1.6 2000/02/27 02:09:40 ekohl Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/kd/kdebug.c
6 * PURPOSE: Kernel debugger
7 * PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
8 * UPDATE HISTORY:
9 * 21/10/99: Created
10 */
11
12 #include <ddk/ntddk.h>
13 #include <internal/ntoskrnl.h>
14 #include <internal/kd.h>
15
16
17 /*
18 * Uncomment one of the following symbols to select a debug output style.
19 *
20 * SCREEN_DEBUGGING:
21 * Debug information is printed on the screen.
22 *
23 * SERIAL_DEBUGGING:
24 * Debug information is printed to a serial device. Check the port
25 * address, the baud rate and the data format.
26 * Default: COM1 19200 Baud 8N1 (8 data bits, no parity, 1 stop bit)
27 *
28 * BOCHS_DEBUGGING: (not tested yet)
29 * Debug information is printed to the bochs logging port. Bochs
30 * writes the output to a log file.
31 */
32
33 #define SCREEN_DEBUGGING /* debug info is printed on the screen */
34 //#define SERIAL_DEBUGGING /* remote debugging */
35 //#define BOCHS_DEBUGGING /* debug output using bochs */
36
37
38 #define SERIAL_DEBUG_PORT 1 /* COM 1 */
39 // #define SERIAL_DEBUG_PORT 2 /* COM 2 */
40 #define SERIAL_DEBUG_BAUD_RATE 19200
41
42
43 //#define BOCHS_DEBUGGING
44 #ifdef BOCHS_DEBUGGING
45 #define BOCHS_LOGGER_PORT (0xe9)
46 #endif
47
48
49 /* VARIABLES ***************************************************************/
50
51 BOOLEAN KdDebuggerEnabled = FALSE; /* EXPORTED */
52 BOOLEAN KdDebuggerNotPresent = TRUE; /* EXPORTED */
53
54
55 /* PRIVATE FUNCTIONS ********************************************************/
56
57 VOID
58 KdInitSystem (VOID)
59 {
60
61 /* FIXME: parse kernel command line */
62
63 /* initialize debug port */
64 #ifdef SERIAL_DEBUGGING
65 KD_PORT_INFORMATION PortInfo;
66
67 PortInfo.ComPort = SERIAL_DEBUG_PORT;
68 PortInfo.BaudRate = SERIAL_DEBUG_BAUD_RATE;
69
70 KdPortInitialize (&PortInfo,
71 0,
72 0);
73 #endif
74 }
75
76
77 ULONG
78 KdpPrintString (PANSI_STRING String)
79 {
80 #if defined(SERIAL_DEBUGGING) || defined(BOCHS_DEBUGGING)
81 PCH pch = String->Buffer;
82 #endif
83
84 #ifdef SCREEN_DEBUGGING
85 HalDisplayString (String->Buffer);
86 #endif
87
88 #ifdef SERIAL_DEBUGGING
89 while (*pch != 0)
90 {
91 if (*pch == '\n')
92 {
93 KdPortPutByte ('\r');
94 }
95
96 KdPortPutByte (*pch);
97
98 pch++;
99 }
100 #endif
101
102 #ifdef BOCHS_DEBUGGING
103 while (*pch != 0)
104 {
105 if (*pch == '\n')
106 {
107 WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, '\r');
108 }
109
110 WRITE_PORT_UCHAR((PUCHAR)BOCHS_LOGGER_PORT, *pch);
111
112 pch++;
113 }
114 #endif
115
116 return (ULONG)String->Length;
117 }
118
119 /* PUBLIC FUNCTIONS *********************************************************/
120
121 /* NTOSKRNL.KdPollBreakIn */
122
123 BYTE
124 STDCALL
125 KdPollBreakIn (
126 VOID
127 )
128 {
129 return KdPortPollByte();
130 }
131
132
133 /* EOF */