📄 purge.cpp
字号:
/*++
Abstract:
This module contains the code that is very specific to purge
operations in the serial driver
--*/
#include "precomp.h"
NTSTATUS KdSerialDevice::StartPurge()
/*++
Routine Description:
Depending on the mask in the current irp, purge the interrupt
buffer, the read queue, or the write queue, or all of the above.
Return Value:
Will return STATUS_SUCCESS always. This is reasonable
since the DPC completion code that calls this routine doesn't
care and the purge request always goes through to completion
once it's started.
--*/
{
KdIrp NewIrp;
do {
ULONG Mask;
Mask = *((PULONG) m_CurrentPurgeIrp.SystemBuffer());
if (Mask & SERIAL_PURGE_TXABORT)
{
KillAllReadsOrWrites(
&m_WriteQueue,
&m_CurrentWriteIrp
);
KillAllReadsOrWrites(
&m_WriteQueue,
&m_CurrentXoffIrp
);
}
if (Mask & SERIAL_PURGE_RXABORT)
{
KillAllReadsOrWrites(
&m_ReadQueue,
&m_CurrentReadIrp
);
}
if (Mask & SERIAL_PURGE_RXCLEAR)
{
// Clean out the interrupt buffer.
//
// Note that we do this under protection of the
// the drivers control lock so that we don't hose
// the pointers if there is currently a read that
// is reading out of the buffer.
m_ControlLock.Lock();
m_KdInterrupt.SynchronizeExecution((KDIRQ_SYNC_CALLBACK) PurgeInterruptBuff);
m_ControlLock.Release();
}
m_CurrentPurgeIrp.Status() = STATUS_SUCCESS;
m_CurrentPurgeIrp.Information() = 0;
GetNextIrp(
&m_CurrentPurgeIrp,
&m_PurgeQueue,
&NewIrp,
TRUE
);
} while (NewIrp);
return STATUS_SUCCESS;
}
BOOLEAN KdSerialDevice::PurgeInterruptBuff()
/*++
Routine Description:
This routine simply resets the interrupt (typeahead) buffer.
NOTE: This routine is being called from KeSynchronizeExecution.
Return Value:
Always false.
--*/
{
// The typeahead buffer is by definition empty if there
// currently is a read owned by the isr.
if (m_ReadBufferBase == m_InterruptReadBuffer)
{
m_CurrentCharSlot = m_InterruptReadBuffer;
m_FirstReadableChar = m_InterruptReadBuffer;
m_LastCharSlot = m_InterruptReadBuffer +
(m_BufferSize - 1);
m_CharsInInterruptBuffer = 0;
HandleReducedIntBuffer();
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -