mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- Synchronize debug messages output to the serial port. Now each line of a debug log is printed synchronously, as it is NT. In future, this should be converted to a generic spinlock for all registered KD handlers.
svn path=/trunk/; revision=40285
This commit is contained in:
parent
fea868eebc
commit
df5b7d2582
1 changed files with 29 additions and 0 deletions
|
@ -21,6 +21,7 @@ BOOLEAN KdpLogInitialized;
|
|||
CHAR DebugBuffer[BufferSize];
|
||||
ULONG CurrentPosition;
|
||||
WORK_QUEUE_ITEM KdpDebugLogQueue;
|
||||
KSPIN_LOCK KdpSerialSpinLock;
|
||||
BOOLEAN ItemQueued;
|
||||
KD_PORT_INFORMATION SerialPortInfo = {DEFAULT_DEBUG_PORT, DEFAULT_DEBUG_BAUD_RATE, 0};
|
||||
|
||||
|
@ -150,8 +151,27 @@ NTAPI
|
|||
KdpSerialDebugPrint(LPSTR Message,
|
||||
ULONG Length)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
PCHAR pch = (PCHAR) Message;
|
||||
|
||||
/* Acquire the printing spinlock without waiting at raised IRQL */
|
||||
while (TRUE)
|
||||
{
|
||||
/* Wait when the spinlock becomes available */
|
||||
while (!KeTestSpinLock(&KdpSerialSpinLock));
|
||||
|
||||
/* Spinlock was free, raise irql */
|
||||
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
||||
|
||||
/* Try to get the spinlock */
|
||||
if (KeTryToAcquireSpinLockAtDpcLevel(&KdpSerialSpinLock))
|
||||
break;
|
||||
|
||||
/* Someone else got the spinlock, lower IRQL back */
|
||||
KeLowerIrql(OldIrql);
|
||||
}
|
||||
|
||||
/* Output the message */
|
||||
while (*pch != 0)
|
||||
{
|
||||
if (*pch == '\n')
|
||||
|
@ -161,6 +181,12 @@ KdpSerialDebugPrint(LPSTR Message,
|
|||
KdPortPutByteEx(&SerialPortInfo, *pch);
|
||||
pch++;
|
||||
}
|
||||
|
||||
/* Release spinlock */
|
||||
KiReleaseSpinLock(&KdpSerialSpinLock);
|
||||
|
||||
/* Lower IRQL */
|
||||
KeLowerIrql(OldIrql);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -184,6 +210,9 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
|
|||
}
|
||||
KdComPortInUse = (PUCHAR)(ULONG_PTR)SerialPortInfo.BaseAddress;
|
||||
|
||||
/* Initialize spinlock */
|
||||
KeInitializeSpinLock(&KdpSerialSpinLock);
|
||||
|
||||
/* Register as a Provider */
|
||||
InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
|
||||
|
||||
|
|
Loading…
Reference in a new issue