📄 waitq.cpp
字号:
// waitq.cpp - implementation of class SerialWaitQueue
//=============================================================================
//
// Compuware Corporation
// NuMega Lab
// 9 Townsend West
// Nashua, NH 03060 USA
//
// Copyright (c) 1998 Compuware Corporation. All Rights Reserved.
// Unpublished - rights reserved under the Copyright laws of the
// United States.
//
//=============================================================================
// Class SerialWaitQueue is derived from KDriverManagedQueue.
// It is used to serialize processing of IOCTLs related to
// event waits.
// Note that when there is a active wait-on-mask operation, the
// IRP for that wait is NOT the current IRP of this queue. The
// interface supports changing the wait mask while a wait is
// progress, and a wait mask of zero terminates a wait.
#include <vdw.h>
#include "serdev.h"
#include "glbtrace.h"
/////////////////////////////////////////////////////////////////////////////
// StartIo
//
// Process next IRP in wait queue.
//
VOID SerialWaitQueue::StartIo(KIrp I)
{
GTRACE((TLEVEL,"WaitQueue::StartIo I=%x\n", I.m_Irp));
ULONG Op = I.IoctlCode();
CancelSpinLock::Acquire();
if (I.WasCanceled())
{
GTRACE((TLEVEL,"WaitQueue: Irp was canceled\n"));
CancelSpinLock::Release();
return;
}
else
{
switch (Op)
{
case IOCTL_SERIAL_SET_WAIT_MASK:
{
ULONG Mask = *(ULONG*)I.IoctlBuffer();
I.SetCancelRoutine(NULL);
CancelSpinLock::Release();
m_Device->StartSetMask(Mask);
I.Status() = STATUS_SUCCESS;
I.Information() = 0;
NextIrp(I);
break;
}
case IOCTL_SERIAL_WAIT_ON_MASK:
m_Device->StartWaitMask();
break;
default:
ASSERT(FALSE);
I.SetCancelRoutine(NULL);
CancelSpinLock::Release();
I.Information()=0;
I.Status() = STATUS_INVALID_PARAMETER;
NextIrp(I);
}
}
}
//////////////////////////////////////////////////////////////////////
// CompleteCurrent
//
// Complete the current IRP with the given status
//
VOID SerialWaitQueue::CompleteCurrent(NTSTATUS status)
{
GTRACE((TLEVEL,"WaitCompleteCurrent enter: %x status=%x\n",m_CurrentIrp.m_Irp, status));
if (status == STATUS_PENDING)
NextIrp( KIrp(0) ); // new waiter
else
{
ASSERT (status != STATUS_SUCCESS);
m_CurrentIrp.Information() = 0;
m_CurrentIrp.Status() = status;
NextIrp(m_CurrentIrp);
}
GTRACE((TLEVEL,"WaitCompleteCurrent leave: %x\n",m_CurrentIrp.m_Irp));
}
//////////////////////////////////////////////////////////////////////
// Cancel
//
VOID SerialWaitQueue::Cancel(KIrp I)
{
GTRACE((TLEVEL,"WaitCancel enter: %x \n",m_CurrentIrp.m_Irp));
GTRACE( (TLEVEL, "WaitQueue: Canceling: %x\n",I.m_Irp));
KDriverManagedQueue::Cancel(I);
GTRACE((TLEVEL,"WaitCancel leave: %x\n",m_CurrentIrp.m_Irp));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -