2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/rtl/dbgprint.c
5 * PURPOSE: Debug output
7 * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de)
10 /* INCLUDES *****************************************************************/
13 #include <internal/debug.h>
15 /* FUNCTIONS ****************************************************************/
18 * Note: DON'T CHANGE THIS FUNCTION!!!
19 * DON'T CALL HalDisplayString OR SOMETING ELSE!!!
20 * You'll only break the serial/bochs debugging feature!!!
27 DbgPrint(PCH Format
, ...)
29 ANSI_STRING DebugString
;
32 #ifdef SERIALIZE_DBGPRINT
33 # define MESSAGETABLE_SIZE 16
36 static LONG TableWriteIndex
= 0, TableReadIndex
= 0;
37 static CHAR MessageTable
[MESSAGETABLE_SIZE
][sizeof(Buffer
)] = { { '\0' } };
38 #endif /* SERIALIZE_DBGPRINT */
40 /* init ansi string */
41 DebugString
.Buffer
= Buffer
;
42 DebugString
.MaximumLength
= sizeof(Buffer
);
44 va_start (ap
, Format
);
45 DebugString
.Length
= _vsnprintf (Buffer
, sizeof( Buffer
), Format
, ap
);
48 #ifdef SERIALIZE_DBGPRINT
49 /* check if we are already running */
50 if (InterlockedCompareExchange(&Lock
, 1, 0) == 1)
52 MyTableIndex
= InterlockedIncrement(&TableWriteIndex
) - 1;
53 InterlockedCompareExchange(&TableWriteIndex
, 0, MESSAGETABLE_SIZE
);
54 MyTableIndex
%= MESSAGETABLE_SIZE
;
56 if (MessageTable
[MyTableIndex
][0] != '\0') /* table is full */
58 DebugString
.Buffer
= "CRITICAL ERROR: DbgPrint Table is FULL!";
59 DebugString
.Length
= 39;
60 KdpPrintString(&DebugString
);
65 /*DebugString.Buffer = "ยตยตยต";
66 DebugString.Length = 3;
67 KdpPrintString(&DebugString);*/
68 memcpy(MessageTable
[MyTableIndex
], DebugString
.Buffer
, DebugString
.Length
);
69 MessageTable
[MyTableIndex
][DebugString
.Length
] = '\0';
74 #endif /* SERIALIZE_DBGPRINT */
75 KdpPrintString (&DebugString
);
76 #ifdef SERIALIZE_DBGPRINT
77 MyTableIndex
= TableReadIndex
;
78 while (MessageTable
[MyTableIndex
][0] != '\0')
80 /*DebugString.Buffer = "$$$";
81 DebugString.Length = 3;
82 KdpPrintString(&DebugString);*/
84 DebugString
.Buffer
= MessageTable
[MyTableIndex
];
85 DebugString
.Length
= strlen(DebugString
.Buffer
);
86 DebugString
.MaximumLength
= DebugString
.Length
+ 1;
88 KdpPrintString(&DebugString
);
89 MessageTable
[MyTableIndex
][0] = '\0';
91 MyTableIndex
= InterlockedIncrement(&TableReadIndex
);
92 InterlockedCompareExchange(&TableReadIndex
, 0, MESSAGETABLE_SIZE
);
93 MyTableIndex
%= MESSAGETABLE_SIZE
;
95 InterlockedDecrement(&Lock
);
97 # undef MESSAGETABLE_SIZE
98 #endif /* SERIALIZE_DBGPRINT */
100 return (ULONG
)DebugString
.Length
;
108 DbgPrintEx(IN ULONG ComponentId
,
122 DbgPrintReturnControlC(PCH Format
,
134 DbgPrompt(PCH OutputString
,
142 Input
.MaximumLength
= InputSize
;
143 Input
.Buffer
= InputString
;
145 Output
.Length
= strlen (OutputString
);
146 Output
.MaximumLength
= Output
.Length
+ 1;
147 Output
.Buffer
= OutputString
;
149 /* FIXME: Not implemented yet!
150 KdpPromptString (&Output, &Input); */
158 DbgQueryDebugFilterState(IN ULONG ComponentId
,
162 return STATUS_NOT_IMPLEMENTED
;
170 DbgSetDebugFilterState(IN ULONG ComponentId
,
175 return STATUS_NOT_IMPLEMENTED
;
183 DbgLoadImageSymbols(IN PUNICODE_STRING Name
,
188 return STATUS_NOT_IMPLEMENTED
;