-/* $Id: dlog.c,v 1.10 2004/01/02 17:43:50 sedwards Exp $
+/* $Id: dlog.c,v 1.16 2004/09/01 00:15:08 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES ******************************************************************/
-#include <ddk/ntddk.h>
-#include <internal/ntoskrnl.h>
-#include <roscfg.h>
-#include <internal/kd.h>
-#include <ntos/minmax.h>
-#include <rosrtl/string.h>
+#include <ntoskrnl.h>
/* GLOBALS *******************************************************************/
static HANDLE DebugLogThreadHandle;
static CLIENT_ID DebugLogThreadCid;
static HANDLE DebugLogFile;
-static KSEMAPHORE DebugLogSem;
+static KEVENT DebugLogEvent;
/* FUNCTIONS *****************************************************************/
+VOID
+DebugLogDumpMessages(VOID)
+{
+ static CHAR Buffer[256];
+ ULONG Offset;
+ ULONG Length;
+
+ if (!(KdDebugState & KD_DEBUG_BOOTLOG))
+ {
+ return;
+ }
+ KdDebugState &= ~KD_DEBUG_BOOTLOG;
+
+ Offset = (DebugLogEnd + 1) % DEBUGLOG_SIZE;
+ do
+ {
+ if (Offset <= DebugLogEnd)
+ {
+ Length = min(255, DebugLogEnd - Offset);
+ }
+ else
+ {
+ Length = min(255, DEBUGLOG_SIZE - Offset);
+ }
+ memcpy(Buffer, DebugLog + Offset, Length);
+ Buffer[Length] = 0;
+ DbgPrint(Buffer);
+ Offset = (Offset + Length) % DEBUGLOG_SIZE;
+ }
+ while (Length > 0);
+}
+
VOID INIT_FUNCTION
DebugLogInit(VOID)
{
DebugLogEnd = 0;
DebugLogOverflow = 0;
DebugLogCount = 0;
- KeInitializeSemaphore(&DebugLogSem, 0, 255);
+ KeInitializeEvent(&DebugLogEvent, NotificationEvent, FALSE);
}
-VOID STDCALL_FUNC
+VOID STDCALL
DebugLogThreadMain(PVOID Context)
{
KIRQL oldIrql;
for (;;)
{
- KeWaitForSingleObject(&DebugLogSem,
+ LARGE_INTEGER TimeOut;
+ TimeOut.QuadPart = -5000000; /* Half a second. */
+ KeWaitForSingleObject(&DebugLogEvent,
0,
KernelMode,
FALSE,
- NULL);
+ &TimeOut);
KeAcquireSpinLock(&DebugLogLock, &oldIrql);
while (DebugLogCount > 0)
{
}
KeAcquireSpinLock(&DebugLogLock, &oldIrql);
}
+ KeResetEvent(&DebugLogEvent);
KeReleaseSpinLock(&DebugLogLock, oldIrql);
}
}
&Iosb,
NULL,
FILE_ATTRIBUTE_NORMAL,
- 0,
+ FILE_SHARE_READ,
FILE_SUPERSEDE,
FILE_WRITE_THROUGH | FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
KeReleaseSpinLock(&DebugLogLock, oldIrql);
if (oldIrql < DISPATCH_LEVEL)
{
- KeReleaseSemaphore(&DebugLogSem, IO_NO_INCREMENT, 1, FALSE);
+ KeSetEvent(&DebugLogEvent, IO_NO_INCREMENT, FALSE);
}
return;
}
KeReleaseSpinLock(&DebugLogLock, oldIrql);
if (oldIrql < DISPATCH_LEVEL)
{
- KeReleaseSemaphore(&DebugLogSem, IO_NO_INCREMENT, 1, FALSE);
+ KeSetEvent(&DebugLogEvent, IO_NO_INCREMENT, FALSE);
}
return;
}
if (oldIrql < DISPATCH_LEVEL)
{
- KeReleaseSemaphore(&DebugLogSem, IO_NO_INCREMENT, 1, FALSE);
+ KeSetEvent(&DebugLogEvent, IO_NO_INCREMENT, FALSE);
}
}