3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/dbg/print.c
6 * PURPOSE: Debug output
8 * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de)
11 /* INCLUDES *****************************************************************/
14 #include <internal/debug.h>
16 /* FUNCTIONS ****************************************************************/
19 ULONG
DbgService (ULONG Service
, PVOID Context1
, PVOID Context2
);
20 __asm__ ("\n\t.global _DbgService\n\t"
22 "mov 4(%esp), %eax\n\t"
23 "mov 8(%esp), %ecx\n\t"
24 "mov 12(%esp), %edx\n\t"
30 * Note: DON'T CHANGE THIS FUNCTION!!!
31 * DON'T CALL HalDisplayString OR SOMETING ELSE!!!
32 * You'll only break the serial/bochs debugging feature!!!
39 DbgPrint(PCH Format
, ...)
41 ANSI_STRING DebugString
;
44 #ifdef SERIALIZE_DBGPRINT
45 # define MESSAGETABLE_SIZE 16
48 static LONG TableWriteIndex
= 0, TableReadIndex
= 0;
49 static CHAR MessageTable
[MESSAGETABLE_SIZE
][sizeof(Buffer
)] = { { '\0' } };
50 #endif /* SERIALIZE_DBGPRINT */
52 /* init ansi string */
53 DebugString
.Buffer
= Buffer
;
54 DebugString
.MaximumLength
= sizeof(Buffer
);
56 va_start (ap
, Format
);
57 DebugString
.Length
= _vsnprintf (Buffer
, sizeof( Buffer
), Format
, ap
);
60 #ifdef SERIALIZE_DBGPRINT
61 /* check if we are already running */
62 if (InterlockedCompareExchange(&Lock
, 1, 0) == 1)
64 MyTableIndex
= InterlockedIncrement(&TableWriteIndex
) - 1;
65 InterlockedCompareExchange(&TableWriteIndex
, 0, MESSAGETABLE_SIZE
);
66 MyTableIndex
%= MESSAGETABLE_SIZE
;
68 if (MessageTable
[MyTableIndex
][0] != '\0') /* table is full */
70 DebugString
.Buffer
= "CRITICAL ERROR: DbgPrint Table is FULL!";
71 DebugString
.Length
= 39;
72 KdpPrintString(&DebugString
);
77 /*DebugString.Buffer = "ยตยตยต";
78 DebugString.Length = 3;
79 KdpPrintString(&DebugString);*/
80 memcpy(MessageTable
[MyTableIndex
], DebugString
.Buffer
, DebugString
.Length
);
81 MessageTable
[MyTableIndex
][DebugString
.Length
] = '\0';
86 #endif /* SERIALIZE_DBGPRINT */
87 KdpPrintString (&DebugString
);
88 #ifdef SERIALIZE_DBGPRINT
89 MyTableIndex
= TableReadIndex
;
90 while (MessageTable
[MyTableIndex
][0] != '\0')
92 /*DebugString.Buffer = "$$$";
93 DebugString.Length = 3;
94 KdpPrintString(&DebugString);*/
96 DebugString
.Buffer
= MessageTable
[MyTableIndex
];
97 DebugString
.Length
= strlen(DebugString
.Buffer
);
98 DebugString
.MaximumLength
= DebugString
.Length
+ 1;
100 KdpPrintString(&DebugString
);
101 MessageTable
[MyTableIndex
][0] = '\0';
103 MyTableIndex
= InterlockedIncrement(&TableReadIndex
);
104 InterlockedCompareExchange(&TableReadIndex
, 0, MESSAGETABLE_SIZE
);
105 MyTableIndex
%= MESSAGETABLE_SIZE
;
107 InterlockedDecrement(&Lock
);
109 # undef MESSAGETABLE_SIZE
110 #endif /* SERIALIZE_DBGPRINT */
112 return (ULONG
)DebugString
.Length
;
121 IN ULONG ComponentId
,
136 DbgPrintReturnControlC(
149 DbgPrompt (PCH OutputString
,
157 Input
.MaximumLength
= InputSize
;
158 Input
.Buffer
= InputString
;
160 Output
.Length
= strlen (OutputString
);
161 Output
.MaximumLength
= Output
.Length
+ 1;
162 Output
.Buffer
= OutputString
;
164 /* FIXME: Not implemented yet! */
165 // KdpPromptString (&Output,
174 DbgQueryDebugFilterState(
175 IN ULONG ComponentId
,
180 return STATUS_NOT_IMPLEMENTED
;
188 DbgSetDebugFilterState(
189 IN ULONG ComponentId
,
195 return STATUS_NOT_IMPLEMENTED
;