flush.cpp

来自「这个是串口驱动程序开发包」· C++ 代码 · 共 80 行

CPP
80
字号
/*++
Abstract:

    This module contains the code that is very specific to flush
    operations in the serial driver
--*/

#include "precomp.h"

NTSTATUS KdSerialDevice::DispatchFlushBuffers(IN KdIrp &Irp)
/*++

Routine Description:

    This is the dispatch routine for flush.  Flushing works by placing
    this request in the write queue.  When this request reaches the
    front of the write queue we simply complete it since this implies
    that all previous writes have completed.

Arguments:

    Irp - Pointer to the IRP for the current request

Return Value:

    Could return status success, cancelled, or pending.
--*/

{
    DebugDump(DBG_DIAG6, ("Dispatch entry for: %x\n",Irp) );
    Irp.Information() = 0L;

    if (CompleteIfError(Irp) != STATUS_SUCCESS)
        return STATUS_CANCELLED;

    return StartOrQueue(
               Irp,
               &m_WriteQueue,
               &m_CurrentWriteIrp,
               StartFlush
               );
}

NTSTATUS KdSerialDevice::StartFlush()
/*++

Routine Description:

    This routine is called if there were no writes in the queue.
    The flush became the current write because there was nothing
    in the queue.  Note however that does not mean there is
    nothing in the queue now!  So, we will start off the write
    that might follow us.

Return Value:

    This will always return STATUS_SUCCESS.

--*/
{
    KdIrp NewIrp;

    m_CurrentWriteIrp.Status() = STATUS_SUCCESS;

    // The following call will actually complete the flush.
    GetNextWrite(
        &m_CurrentWriteIrp,
        &m_WriteQueue,
        &NewIrp,
        TRUE
        );

    if (NewIrp) 
    {
        ASSERT(NewIrp == m_CurrentWriteIrp);
        StartWrite();
    }
    return STATUS_SUCCESS;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?